From f04a0bb0e66303e1cc0564e70f8ce14ffce56548 Mon Sep 17 00:00:00 2001 From: Fu Zi Xiang Date: Thu, 9 Nov 2023 16:19:02 +0800 Subject: [PATCH] feat: improve message box --- admin_frontend/src/web_api.rs | 14 +++++++------- admin_frontend/templates/components/invite.html | 10 ++-------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/admin_frontend/src/web_api.rs b/admin_frontend/src/web_api.rs index e04283b8..9b5b45a5 100644 --- a/admin_frontend/src/web_api.rs +++ b/admin_frontend/src/web_api.rs @@ -72,21 +72,21 @@ pub async fn invite_handler( }, ) .await?; - Ok(WebApiResponse::from(())) + Ok(WebApiResponse::<()>::from_str("Invitation sent".into())) } pub async fn change_password_handler( State(state): State, session: UserSession, Form(param): Form, -) -> Result, WebApiError<'static>> { +) -> Result, WebApiError<'static>> { if param.new_password != param.confirm_password { return Err(WebApiError::new( status::StatusCode::BAD_REQUEST, "passwords do not match", )); } - let res = state + let _user = state .gotrue_client .update_user( &session.token.access_token, @@ -96,7 +96,7 @@ pub async fn change_password_handler( }, ) .await?; - Ok(res.into()) + Ok(WebApiResponse::<()>::from_str("Password changed".into())) } static DEFAULT_HOST: HeaderValue = HeaderValue::from_static("localhost"); @@ -186,18 +186,18 @@ pub async fn admin_add_user_handler( State(state): State, session: UserSession, Form(param): Form, -) -> Result, WebApiError<'static>> { +) -> Result, WebApiError<'static>> { let add_user_params = AdminUserParams { email: param.email, password: Some(param.password), email_confirm: !param.require_email_verification, ..Default::default() }; - let user = state + let _user = state .gotrue_client .admin_add_user(&session.token.access_token, &add_user_params) .await?; - Ok(user.into()) + Ok(WebApiResponse::<()>::from_str("User created".into())) } pub async fn login_refresh_handler( diff --git a/admin_frontend/templates/components/invite.html b/admin_frontend/templates/components/invite.html index 4df6e1df..34af82c2 100644 --- a/admin_frontend/templates/components/invite.html +++ b/admin_frontend/templates/components/invite.html @@ -1,6 +1,6 @@

Please enter the following email invite a new user

-
+ @@ -16,13 +16,7 @@
Email:
-