From c18d6927ba96818c925f662c17a6a9fda0752c34 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 27 Jun 2025 00:00:06 +0800 Subject: [PATCH] chore: update user session table --- server/router/api/v1/auth_service.go | 10 -------- web/src/components/Navigation.tsx | 2 +- .../Settings/UserSessionsSection.tsx | 24 ------------------- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/server/router/api/v1/auth_service.go b/server/router/api/v1/auth_service.go index 742c2caf8..be34a2699 100644 --- a/server/router/api/v1/auth_service.go +++ b/server/router/api/v1/auth_service.go @@ -229,16 +229,6 @@ func (s *APIV1Service) DeleteSession(ctx context.Context, _ *v1pb.DeleteSessionR } } - // Check if we have an access token (from header-based auth) - if accessToken, ok := ctx.Value(accessTokenContextKey).(string); ok && accessToken != "" { - // Delete the access token from the store - if _, err := s.DeleteUserAccessToken(ctx, &v1pb.DeleteUserAccessTokenRequest{ - Name: fmt.Sprintf("%s%d/accessTokens/%s", UserNamePrefix, user.ID, accessToken), - }); err != nil { - slog.Error("failed to delete access token", "error", err) - } - } - if err := s.clearAuthCookies(ctx); err != nil { return nil, status.Errorf(codes.Internal, "failed to clear auth cookies, error: %v", err) } diff --git a/web/src/components/Navigation.tsx b/web/src/components/Navigation.tsx index 5e72b6b83..5977ffe8d 100644 --- a/web/src/components/Navigation.tsx +++ b/web/src/components/Navigation.tsx @@ -71,7 +71,7 @@ const Navigation = observer((props: Props) => { )} >
- + {navLinks.map((navLink) => ( diff --git a/web/src/components/Settings/UserSessionsSection.tsx b/web/src/components/Settings/UserSessionsSection.tsx index 135d07f0d..74e8c800a 100644 --- a/web/src/components/Settings/UserSessionsSection.tsx +++ b/web/src/components/Settings/UserSessionsSection.tsx @@ -60,18 +60,6 @@ const UserSessionsSection = () => { return parts.length > 0 ? parts.join(" • ") : "Unknown Device"; }; - const getSessionExpirationDate = (session: UserSession) => { - if (!session.lastAccessedTime) return null; - // Calculate expiration as last_accessed_time + 2 weeks (14 days) - const expirationDate = new Date(session.lastAccessedTime.getTime() + 14 * 24 * 60 * 60 * 1000); - return expirationDate; - }; - - const isSessionExpired = (session: UserSession) => { - const expirationDate = getSessionExpirationDate(session); - return expirationDate ? expirationDate < new Date() : false; - }; - const isCurrentSession = (session: UserSession) => { // A simple heuristic: the most recently accessed session is likely the current one if (userSessions.length === 0) return false; @@ -103,9 +91,6 @@ const UserSessionsSection = () => { {t("setting.user-sessions-section.last-active")} - - {t("setting.user-sessions-section.expires")} - {t("common.delete")} @@ -137,15 +122,6 @@ const UserSessionsSection = () => { {userSession.lastAccessedTime?.toLocaleString()}
- -
- - - {getSessionExpirationDate(userSession)?.toLocaleString() ?? t("setting.user-sessions-section.never")} - {isSessionExpired(userSession) && (Expired)} - -
-