From 67c1ef693f57f3617947bd0a8a5f3a0311f5f695 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Wed, 3 Apr 2024 21:31:33 +0800 Subject: [PATCH] feat: use session login instead --- admin_frontend/src/web_api.rs | 17 ++--------------- admin_frontend/templates/pages/login.html | 1 - 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/admin_frontend/src/web_api.rs b/admin_frontend/src/web_api.rs index e128b9bc..10914380 100644 --- a/admin_frontend/src/web_api.rs +++ b/admin_frontend/src/web_api.rs @@ -298,7 +298,7 @@ pub async fn login_refresh_handler( State(state): State, jar: CookieJar, Path(refresh_token): Path, -) -> Result> { +) -> Result<(CookieJar, HeaderMap, WebApiResponse<()>), WebApiError<'static>> { let token = state .gotrue_client .token(&gotrue::grant::Grant::RefreshToken( @@ -316,20 +316,7 @@ pub async fn login_refresh_handler( )) .await?; - verify_token_cloud( - token.access_token.as_str(), - state.appflowy_cloud_url.as_str(), - ) - .await?; - - let new_session_id = uuid::Uuid::new_v4(); - let new_session = session::UserSession::new(new_session_id.to_string(), token); - state.session_store.put_user_session(&new_session).await?; - - let mut cookie = Cookie::new("session_id", new_session_id.to_string()); - cookie.set_path("/"); - - Ok(jar.add(cookie)) + session_login(State(state), token, jar).await } // login and set the cookie diff --git a/admin_frontend/templates/pages/login.html b/admin_frontend/templates/pages/login.html index ad33401a..81697657 100644 --- a/admin_frontend/templates/pages/login.html +++ b/admin_frontend/templates/pages/login.html @@ -146,7 +146,6 @@ } } }); - } {% endblock %}