From f89e44d5b969b625774e60746b4bced8f40761c6 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 30 Aug 2024 14:56:13 +0800 Subject: [PATCH] redirect archived user to /account-archived page when login --- packages/api/src/routers/auth/auth_router.ts | 4 ++-- packages/api/src/routers/auth/google_auth.ts | 6 ++++-- packages/api/src/routers/export_router.ts | 1 - packages/api/src/utils/navigation.ts | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index 4081c0b79f..ed88d92377 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -35,7 +35,7 @@ import { } from '../../utils/auth' import { corsConfig } from '../../utils/corsConfig' import { logger } from '../../utils/logger' -import { DEFAULT_HOME_PATH } from '../../utils/navigation' +import { ARCHIVE_ACCOUNT_PATH, DEFAULT_HOME_PATH } from '../../utils/navigation' import { hourlyLimiter } from '../../utils/rate_limit' import { verifyChallengeRecaptcha } from '../../utils/recaptcha' import { createSsoToken, ssoRedirectURL } from '../../utils/sso' @@ -379,7 +379,7 @@ export function authRouter() { } if (user.status === StatusType.Archived) { - redirectUri = `${env.client.url}/export` + redirectUri = `${env.client.url}${ARCHIVE_ACCOUNT_PATH}` } redirectUri = redirectUri ?? `${env.client.url}${DEFAULT_HOME_PATH}` diff --git a/packages/api/src/routers/auth/google_auth.ts b/packages/api/src/routers/auth/google_auth.ts index 5f2fa87f89..65cb2efcaa 100644 --- a/packages/api/src/routers/auth/google_auth.ts +++ b/packages/api/src/routers/auth/google_auth.ts @@ -6,7 +6,7 @@ import { env, homePageURL } from '../../env' import { LoginErrorCode } from '../../generated/graphql' import { userRepository } from '../../repository/user' import { logger } from '../../utils/logger' -import { DEFAULT_HOME_PATH } from '../../utils/navigation' +import { ARCHIVE_ACCOUNT_PATH, DEFAULT_HOME_PATH } from '../../utils/navigation' import { createSsoToken, ssoRedirectURL } from '../../utils/sso' import { DecodeTokenResult } from './auth_types' import { createPendingUserToken, createWebAuthToken } from './jwt_helpers' @@ -158,7 +158,9 @@ export async function handleGoogleWebAuth( } let redirectURL = `${baseURL()}${ - user.status === StatusType.Archived ? '/export' : DEFAULT_HOME_PATH + user.status === StatusType.Archived + ? ARCHIVE_ACCOUNT_PATH + : DEFAULT_HOME_PATH }` const authToken = await createWebAuthToken(userId) diff --git a/packages/api/src/routers/export_router.ts b/packages/api/src/routers/export_router.ts index 7b2a82ba8c..aac22e172a 100644 --- a/packages/api/src/routers/export_router.ts +++ b/packages/api/src/routers/export_router.ts @@ -3,7 +3,6 @@ import express, { Router } from 'express' import { TaskState } from '../generated/graphql' import { jobStateToTaskState } from '../queue-processor' import { countExportsWithin24Hours, saveExport } from '../services/export' -import { sendExportJobEmail } from '../services/send_emails' import { getClaimsByToken, getTokenByRequest } from '../utils/auth' import { corsConfig } from '../utils/corsConfig' import { queueExportJob } from '../utils/createTask' diff --git a/packages/api/src/utils/navigation.ts b/packages/api/src/utils/navigation.ts index 0416cc573b..c2a39c9039 100644 --- a/packages/api/src/utils/navigation.ts +++ b/packages/api/src/utils/navigation.ts @@ -1 +1,2 @@ export const DEFAULT_HOME_PATH = '/home' +export const ARCHIVE_ACCOUNT_PATH = '/account-archived'