feat: improve message box
This commit is contained in:
parent
f149f21f61
commit
f04a0bb0e6
|
|
@ -72,21 +72,21 @@ pub async fn invite_handler(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(WebApiResponse::from(()))
|
Ok(WebApiResponse::<()>::from_str("Invitation sent".into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn change_password_handler(
|
pub async fn change_password_handler(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
session: UserSession,
|
session: UserSession,
|
||||||
Form(param): Form<WebApiChangePasswordRequest>,
|
Form(param): Form<WebApiChangePasswordRequest>,
|
||||||
) -> Result<WebApiResponse<User>, WebApiError<'static>> {
|
) -> Result<WebApiResponse<()>, WebApiError<'static>> {
|
||||||
if param.new_password != param.confirm_password {
|
if param.new_password != param.confirm_password {
|
||||||
return Err(WebApiError::new(
|
return Err(WebApiError::new(
|
||||||
status::StatusCode::BAD_REQUEST,
|
status::StatusCode::BAD_REQUEST,
|
||||||
"passwords do not match",
|
"passwords do not match",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let res = state
|
let _user = state
|
||||||
.gotrue_client
|
.gotrue_client
|
||||||
.update_user(
|
.update_user(
|
||||||
&session.token.access_token,
|
&session.token.access_token,
|
||||||
|
|
@ -96,7 +96,7 @@ pub async fn change_password_handler(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(res.into())
|
Ok(WebApiResponse::<()>::from_str("Password changed".into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFAULT_HOST: HeaderValue = HeaderValue::from_static("localhost");
|
static DEFAULT_HOST: HeaderValue = HeaderValue::from_static("localhost");
|
||||||
|
|
@ -186,18 +186,18 @@ pub async fn admin_add_user_handler(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
session: UserSession,
|
session: UserSession,
|
||||||
Form(param): Form<WebApiAdminCreateUserRequest>,
|
Form(param): Form<WebApiAdminCreateUserRequest>,
|
||||||
) -> Result<WebApiResponse<User>, WebApiError<'static>> {
|
) -> Result<WebApiResponse<()>, WebApiError<'static>> {
|
||||||
let add_user_params = AdminUserParams {
|
let add_user_params = AdminUserParams {
|
||||||
email: param.email,
|
email: param.email,
|
||||||
password: Some(param.password),
|
password: Some(param.password),
|
||||||
email_confirm: !param.require_email_verification,
|
email_confirm: !param.require_email_verification,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let user = state
|
let _user = state
|
||||||
.gotrue_client
|
.gotrue_client
|
||||||
.admin_add_user(&session.token.access_token, &add_user_params)
|
.admin_add_user(&session.token.access_token, &add_user_params)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(user.into())
|
Ok(WebApiResponse::<()>::from_str("User created".into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn login_refresh_handler(
|
pub async fn login_refresh_handler(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<div id="invite-user">
|
<div id="invite-user">
|
||||||
<h4>Please enter the following email invite a new user</h4>
|
<h4>Please enter the following email invite a new user</h4>
|
||||||
<form>
|
<form hx-post="/web-api/invite" hx-target="#none">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Email:</td>
|
<td>Email:</td>
|
||||||
|
|
@ -16,13 +16,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<button
|
<button class="button cyan" type="submit">
|
||||||
hx-post="/web-api/invite"
|
|
||||||
hx-target="#none"
|
|
||||||
class="button cyan"
|
|
||||||
type="submit"
|
|
||||||
id="inviteBtn"
|
|
||||||
>
|
|
||||||
Invite
|
Invite
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue