Skip to content

Commit

Permalink
redirect archived user to /account-archived page when login
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Aug 30, 2024
1 parent 2ff987d commit f89e44d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/routers/auth/auth_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}`
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/routers/auth/google_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/routers/export_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/utils/navigation.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const DEFAULT_HOME_PATH = '/home'
export const ARCHIVE_ACCOUNT_PATH = '/account-archived'

0 comments on commit f89e44d

Please sign in to comment.