Set default home redirect path
This commit is contained in:
@ -16,6 +16,7 @@ import {
|
||||
createWebAuthToken,
|
||||
suggestedUsername,
|
||||
} from './jwt_helpers'
|
||||
import { DEFAULT_HOME_PATH } from '../../utils/navigation'
|
||||
|
||||
const appleBaseURL = 'https://appleid.apple.com'
|
||||
const audienceName = 'app.omnivore.app'
|
||||
@ -142,10 +143,13 @@ export async function handleAppleWebAuth(
|
||||
|
||||
const authToken = await createWebAuthToken(userId)
|
||||
if (authToken) {
|
||||
const ssoToken = createSsoToken(authToken, `${baseURL()}/home`)
|
||||
const ssoToken = createSsoToken(
|
||||
authToken,
|
||||
`${baseURL()}${DEFAULT_HOME_PATH}`
|
||||
)
|
||||
const redirectURL = isVercel
|
||||
? ssoRedirectURL(ssoToken)
|
||||
: `${baseURL()}/home`
|
||||
: `${baseURL()}${DEFAULT_HOME_PATH}`
|
||||
|
||||
analytics.capture({
|
||||
distinctId: user.id,
|
||||
|
||||
@ -48,6 +48,7 @@ import {
|
||||
} from './google_auth'
|
||||
import { createWebAuthToken } from './jwt_helpers'
|
||||
import { createMobileAccountCreationResponse } from './mobile/account_creation'
|
||||
import { DEFAULT_HOME_PATH } from '../../utils/navigation'
|
||||
|
||||
export interface SignupRequest {
|
||||
email: string
|
||||
@ -373,11 +374,13 @@ export function authRouter() {
|
||||
decodeURIComponent(redirectUri)
|
||||
)
|
||||
} else {
|
||||
redirectUri = `${env.client.url}/home`
|
||||
redirectUri = `${env.client.url}${DEFAULT_HOME_PATH}`
|
||||
}
|
||||
}
|
||||
|
||||
redirectUri = redirectUri ? redirectUri : `${env.client.url}/home`
|
||||
redirectUri = redirectUri
|
||||
? redirectUri
|
||||
: `${env.client.url}${DEFAULT_HOME_PATH}`
|
||||
|
||||
const message = res.get('Message')
|
||||
if (message) {
|
||||
|
||||
@ -9,6 +9,7 @@ import { logger } from '../../utils/logger'
|
||||
import { createSsoToken, ssoRedirectURL } from '../../utils/sso'
|
||||
import { DecodeTokenResult } from './auth_types'
|
||||
import { createPendingUserToken, createWebAuthToken } from './jwt_helpers'
|
||||
import { DEFAULT_HOME_PATH } from '../../utils/navigation'
|
||||
|
||||
export const googleAuthMobile = (): OAuth2Client =>
|
||||
new google.auth.OAuth2(env.google.auth.clientId, env.google.auth.secret)
|
||||
@ -159,10 +160,13 @@ export async function handleGoogleWebAuth(
|
||||
|
||||
const authToken = await createWebAuthToken(userId)
|
||||
if (authToken) {
|
||||
const ssoToken = createSsoToken(authToken, `${baseURL()}/home`)
|
||||
const ssoToken = createSsoToken(
|
||||
authToken,
|
||||
`${baseURL()}${DEFAULT_HOME_PATH}`
|
||||
)
|
||||
const redirectURL = isVercel
|
||||
? ssoRedirectURL(ssoToken)
|
||||
: `${baseURL()}/home`
|
||||
: `${baseURL()}${DEFAULT_HOME_PATH}`
|
||||
|
||||
return {
|
||||
authToken,
|
||||
|
||||
1
packages/api/src/utils/navigation.ts
Normal file
1
packages/api/src/utils/navigation.ts
Normal file
@ -0,0 +1 @@
|
||||
export const DEFAULT_HOME_PATH = `/l/home`
|
||||
@ -1,5 +1,6 @@
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import { DEFAULT_HOME_PATH } from '../../../lib/navigations'
|
||||
export type OmnivoreLogoBaseProps = {
|
||||
color?: string
|
||||
href?: string
|
||||
@ -28,9 +29,9 @@ export function OmnivoreLogoBase(props: OmnivoreLogoBaseProps): JSX.Element {
|
||||
}
|
||||
const query = window.sessionStorage.getItem('q')
|
||||
if (query) {
|
||||
window.location.assign(`/l/home?${query}`)
|
||||
window.location.assign(`${DEFAULT_HOME_PATH}?${query}`)
|
||||
} else {
|
||||
window.location.replace(`/l/home`)
|
||||
window.location.replace(DEFAULT_HOME_PATH)
|
||||
}
|
||||
}}
|
||||
tabIndex={-1}
|
||||
|
||||
@ -14,6 +14,7 @@ import { SettingsDropdown } from './navMenu/SettingsDropdown'
|
||||
import { useVerifyAuth } from '../../lib/hooks/useVerifyAuth'
|
||||
import Link from 'next/link'
|
||||
import { CaretLeft } from '@phosphor-icons/react'
|
||||
import { DEFAULT_HOME_PATH } from '../../lib/navigations'
|
||||
|
||||
type SettingsLayoutProps = {
|
||||
title?: string
|
||||
@ -32,7 +33,7 @@ const ReturnButton = (): JSX.Element => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Link href="/l/home">
|
||||
<Link href={DEFAULT_HOME_PATH}>
|
||||
<HStack
|
||||
css={{
|
||||
pl: '20px',
|
||||
|
||||
@ -21,6 +21,7 @@ import { NotebookContent } from './Notebook'
|
||||
import { NotebookHeader } from './NotebookHeader'
|
||||
import useWindowDimensions from '../../../lib/hooks/useGetWindowDimensions'
|
||||
import { ResizableSidebar } from './ResizableSidebar'
|
||||
import { DEFAULT_HOME_PATH } from '../../../lib/navigations'
|
||||
|
||||
export type PdfArticleContainerProps = {
|
||||
viewer: UserBasicData
|
||||
@ -455,9 +456,9 @@ export default function PdfArticleContainer(
|
||||
}
|
||||
const query = window.sessionStorage.getItem('q')
|
||||
if (query) {
|
||||
window.location.assign(`/l/home?${query}`)
|
||||
window.location.assign(`${DEFAULT_HOME_PATH}?${query}`)
|
||||
} else {
|
||||
window.location.replace(`/l/home`)
|
||||
window.location.replace(DEFAULT_HOME_PATH)
|
||||
}
|
||||
break
|
||||
case 'e':
|
||||
|
||||
1
packages/web/lib/navigations.ts
Normal file
1
packages/web/lib/navigations.ts
Normal file
@ -0,0 +1 @@
|
||||
export const DEFAULT_HOME_PATH = `/l/home`
|
||||
@ -24,6 +24,7 @@ import { ThemeId } from '../components/tokens/stitches.config'
|
||||
import { posthog } from 'posthog-js'
|
||||
import { GoogleReCaptchaProvider } from '@google-recaptcha/react'
|
||||
import { SWRConfig } from 'swr'
|
||||
import { DEFAULT_HOME_PATH } from '../lib/navigations'
|
||||
|
||||
TopBarProgress.config({
|
||||
barColors: {
|
||||
@ -48,7 +49,7 @@ const generateActions = (router: NextRouter) => {
|
||||
router.push(navReturn)
|
||||
return
|
||||
}
|
||||
router?.push('/l/home')
|
||||
router?.push(DEFAULT_HOME_PATH)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@ import { serialize } from 'cookie'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
import { withSentry } from '@sentry/nextjs'
|
||||
import { ssoJwtSecret } from '../../../lib/appConfig'
|
||||
import { DEFAULT_HOME_PATH } from '../../../lib/navigations'
|
||||
|
||||
type AuthPayload = {
|
||||
authToken: string
|
||||
@ -29,7 +30,7 @@ const requestHandler = (req: NextApiRequest, res: NextApiResponse): void => {
|
||||
})
|
||||
} else {
|
||||
res.writeHead(302, {
|
||||
Location: '/l/home',
|
||||
Location: DEFAULT_HOME_PATH,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
|
||||
import { PageMetaData } from '../components/patterns/PageMetaData'
|
||||
import { LoadingView } from '../components/patterns/LoadingView'
|
||||
import { About } from '../components/templates/About'
|
||||
import { DEFAULT_HOME_PATH } from '../lib/navigations'
|
||||
|
||||
export default function LandingPage(): JSX.Element {
|
||||
const router = useRouter()
|
||||
@ -13,7 +14,7 @@ export default function LandingPage(): JSX.Element {
|
||||
if (navReturn) {
|
||||
router.push(navReturn)
|
||||
} else {
|
||||
router.push('/l/home')
|
||||
router.push(DEFAULT_HOME_PATH)
|
||||
}
|
||||
return <></>
|
||||
} else if (isLoading || !router.isReady) {
|
||||
|
||||
@ -19,6 +19,7 @@ import {
|
||||
BorderedFormInput,
|
||||
FormLabel,
|
||||
} from '../../components/elements/FormElements'
|
||||
import { DEFAULT_HOME_PATH } from '../../lib/navigations'
|
||||
|
||||
type RunningState = 'none' | 'confirming' | 'running' | 'completed'
|
||||
|
||||
@ -202,7 +203,7 @@ export default function BulkPerformer(): JSX.Element {
|
||||
<VStack css={{ width: '100%' }} alignment="center">
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
window.location.href = '/l/home'
|
||||
window.location.href = DEFAULT_HOME_PATH
|
||||
e.preventDefault()
|
||||
}}
|
||||
style="ctaDarkYellow"
|
||||
|
||||
@ -240,7 +240,7 @@ export default function ImportUploader(): JSX.Element {
|
||||
{uploadState == 'completed' && (
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
window.location.href = '/l/home'
|
||||
window.location.href = DEFAULT_HOME_PATH
|
||||
e.preventDefault()
|
||||
}}
|
||||
style="ctaDarkYellow"
|
||||
|
||||
@ -16,6 +16,7 @@ import Dropzone from 'react-dropzone'
|
||||
import { SyncLoader } from 'react-spinners'
|
||||
import { theme } from '../../../components/tokens/stitches.config'
|
||||
import { Tray } from '@phosphor-icons/react'
|
||||
import { DEFAULT_HOME_PATH } from '../../../lib/navigations'
|
||||
|
||||
type UploadState = 'none' | 'uploading' | 'completed'
|
||||
|
||||
@ -190,7 +191,7 @@ export default function ImportUploader(): JSX.Element {
|
||||
<VStack css={{ width: '100%' }} alignment="center">
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
window.location.href = '/l/home'
|
||||
window.location.href = DEFAULT_HOME_PATH
|
||||
e.preventDefault()
|
||||
}}
|
||||
style="ctaDarkYellow"
|
||||
|
||||
Reference in New Issue
Block a user