diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index 892fdc40c..9a618279a 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -340,7 +340,7 @@ export function authRouter() { ) } return res.redirect( - `${env.client.url}/settings/installation/extensions` + `${env.client.url}/home` ) } @@ -377,7 +377,7 @@ export function authRouter() { if (!email || !password) { return res.redirect( - `${env.client.url}/email-login?errorCodes=${LoginErrorCode.InvalidCredentials}` + `${env.client.url}/auth/email-login?errorCodes=${LoginErrorCode.InvalidCredentials}` ) } @@ -388,7 +388,7 @@ export function authRouter() { }) if (!user?.id) { return res.redirect( - `${env.client.url}/email-login?errorCodes=${LoginErrorCode.UserNotFound}` + `${env.client.url}/auth/email-login?errorCodes=${LoginErrorCode.UserNotFound}` ) } @@ -399,14 +399,14 @@ export function authRouter() { name: user.name, }) return res.redirect( - `${env.client.url}/email-login?errorCodes=PENDING_VERIFICATION` + `${env.client.url}/auth/email-login?errorCodes=PENDING_VERIFICATION` ) } if (!user?.password) { // user has no password, so they need to set one return res.redirect( - `${env.client.url}/email-login?errorCodes=${LoginErrorCode.WrongSource}` + `${env.client.url}/auth/email-login?errorCodes=${LoginErrorCode.WrongSource}` ) } @@ -414,7 +414,7 @@ export function authRouter() { const validPassword = await comparePassword(password, user.password) if (!validPassword) { return res.redirect( - `${env.client.url}/email-login?errorCodes=${LoginErrorCode.InvalidCredentials}` + `${env.client.url}/auth/email-login?errorCodes=${LoginErrorCode.InvalidCredentials}` ) } @@ -423,7 +423,7 @@ export function authRouter() { await handleSuccessfulLogin(req, res, user, false) } catch (e) { logger.info('email-login exception:', e) - res.redirect(`${env.client.url}/email-login?errorCodes=AUTH_FAILED`) + res.redirect(`${env.client.url}/auth/email-login?errorCodes=AUTH_FAILED`) } } ) @@ -441,7 +441,7 @@ export function authRouter() { if (!email || !password || !name || !username) { return res.redirect( - `${env.client.url}/email-signup?errorCodes=INVALID_CREDENTIALS` + `${env.client.url}/auth/email-signup?errorCodes=INVALID_CREDENTIALS` ) } const lowerCasedUsername = username.toLowerCase() @@ -462,15 +462,15 @@ export function authRouter() { pendingConfirmation: true, }) - res.redirect(`${env.client.url}/verify-email?message=SIGNUP_SUCCESS`) + res.redirect(`${env.client.url}/auth/verify-email?message=SIGNUP_SUCCESS`) } catch (e) { logger.info('email-signup exception:', e) if (isErrorWithCode(e)) { return res.redirect( - `${env.client.url}/email-signup?errorCodes=${e.errorCode}` + `${env.client.url}/auth/email-signup?errorCodes=${e.errorCode}` ) } - res.redirect(`${env.client.url}/email-signup?errorCodes=UNKNOWN`) + res.redirect(`${env.client.url}/auth/email-signup?errorCodes=UNKNOWN`) } } ) @@ -491,14 +491,14 @@ export function authRouter() { const claims = await getClaimsByToken(token) if (!claims) { return res.redirect( - `${env.client.url}/confirm-email?errorCodes=INVALID_TOKEN` + `${env.client.url}/auth/confirm-email?errorCodes=INVALID_TOKEN` ) } const user = await getRepository(User).findOneBy({ id: claims.uid }) if (!user) { return res.redirect( - `${env.client.url}/confirm-email?errorCodes=USER_NOT_FOUND` + `${env.client.url}/auth/confirm-email?errorCodes=USER_NOT_FOUND` ) } @@ -514,7 +514,7 @@ export function authRouter() { if (!updated.affected) { return res.redirect( - `${env.client.url}/confirm-email?errorCodes=UNKNOWN` + `${env.client.url}/auth/confirm-email?errorCodes=UNKNOWN` ) } } @@ -526,11 +526,11 @@ export function authRouter() { logger.info('confirm-email exception:', e) if (e instanceof jwt.TokenExpiredError) { return res.redirect( - `${env.client.url}/confirm-email?errorCodes=TOKEN_EXPIRED` + `${env.client.url}/auth/confirm-email?errorCodes=TOKEN_EXPIRED` ) } - res.redirect(`${env.client.url}/confirm-email?errorCodes=INVALID_TOKEN`) + res.redirect(`${env.client.url}/auth/confirm-email?errorCodes=INVALID_TOKEN`) } } ) @@ -547,7 +547,7 @@ export function authRouter() { const email = req.body.email if (!email) { return res.redirect( - `${env.client.url}/forgot-password?errorCodes=INVALID_EMAIL` + `${env.client.url}/auth/forgot-password?errorCodes=INVALID_EMAIL` ) } @@ -557,27 +557,27 @@ export function authRouter() { }) if (!user) { return res.redirect( - `${env.client.url}/forgot-password?errorCodes=USER_NOT_FOUND` + `${env.client.url}/auth/forgot-password?errorCodes=USER_NOT_FOUND` ) } if (user.status === StatusType.Pending) { return res.redirect( - `${env.client.url}/email-login?errorCodes=PENDING_VERIFICATION` + `${env.client.url}/auth/email-login?errorCodes=PENDING_VERIFICATION` ) } if (!(await sendPasswordResetEmail(user))) { return res.redirect( - `${env.client.url}/forgot-password?errorCodes=INVALID_EMAIL` + `${env.client.url}/auth/forgot-password?errorCodes=INVALID_EMAIL` ) } - res.redirect(`${env.client.url}/forgot-password?message=SUCCESS`) + res.redirect(`${env.client.url}/auth/forgot-password?message=SUCCESS`) } catch (e) { logger.info('forgot-password exception:', e) - res.redirect(`${env.client.url}/forgot-password?errorCodes=UNKNOWN`) + res.redirect(`${env.client.url}/auth/forgot-password?errorCodes=UNKNOWN`) } } ) @@ -598,26 +598,26 @@ export function authRouter() { const claims = await getClaimsByToken(token) if (!claims) { return res.redirect( - `${env.client.url}/reset-password?errorCodes=INVALID_TOKEN` + `${env.client.url}/auth/reset-password?errorCodes=INVALID_TOKEN` ) } if (!password) { return res.redirect( - `${env.client.url}/reset-password?errorCodes=INVALID_PASSWORD` + `${env.client.url}/auth/reset-password?errorCodes=INVALID_PASSWORD` ) } const user = await getRepository(User).findOneBy({ id: claims.uid }) if (!user) { return res.redirect( - `${env.client.url}/reset-password?errorCodes=USER_NOT_FOUND` + `${env.client.url}/auth/reset-password?errorCodes=USER_NOT_FOUND` ) } if (user.status === StatusType.Pending) { return res.redirect( - `${env.client.url}/email-login?errorCodes=PENDING_VERIFICATION` + `${env.client.url}/auth/email-login?errorCodes=PENDING_VERIFICATION` ) } @@ -632,21 +632,21 @@ export function authRouter() { ) if (!updated.affected) { return res.redirect( - `${env.client.url}/reset-password?errorCodes=UNKNOWN` + `${env.client.url}/auth/reset-password?errorCodes=UNKNOWN` ) } - res.redirect(`${env.client.url}/reset-password?message=SUCCESS`) + res.redirect(`${env.client.url}/auth/reset-password?message=SUCCESS`) } catch (e) { logger.info('reset-password exception:', e) if (e instanceof jwt.TokenExpiredError) { return res.redirect( - `${env.client.url}/reset-password?errorCodes=TOKEN_EXPIRED` + `${env.client.url}/auth/reset-password?errorCodes=TOKEN_EXPIRED` ) } res.redirect( - `${env.client.url}/reset-password?errorCodes=INVALID_TOKEN` + `${env.client.url}/auth/reset-password?errorCodes=INVALID_TOKEN` ) } } diff --git a/packages/api/src/services/send_emails.ts b/packages/api/src/services/send_emails.ts index a6fbf6d42..2ebefd3d1 100644 --- a/packages/api/src/services/send_emails.ts +++ b/packages/api/src/services/send_emails.ts @@ -9,7 +9,7 @@ export const sendConfirmationEmail = async (user: { }): Promise => { // generate confirmation link const token = generateVerificationToken(user.id) - const link = `${env.client.url}/confirm-email/${token}` + const link = `${env.client.url}/auth/confirm-email/${token}` // send email const dynamicTemplateData = { name: user.name, @@ -31,7 +31,7 @@ export const sendPasswordResetEmail = async (user: { }): Promise => { // generate link const token = generateVerificationToken(user.id) - const link = `${env.client.url}/reset-password/${token}` + const link = `${env.client.url}/auth/reset-password/${token}` // send email const dynamicTemplateData = { name: user.name, diff --git a/packages/api/test/routers/auth.test.ts b/packages/api/test/routers/auth.test.ts index 526ccce02..fa14521be 100644 --- a/packages/api/test/routers/auth.test.ts +++ b/packages/api/test/routers/auth.test.ts @@ -499,7 +499,7 @@ describe('auth router', () => { 302 ) expect(res.header.location).to.endWith( - '/reset-password?message=SUCCESS' + '/auth/reset-password?message=SUCCESS' ) }) @@ -518,7 +518,7 @@ describe('auth router', () => { it('redirects to reset-password page with error code INVALID_PASSWORD', async () => { const res = await resetPasswordRequest(token, '').expect(302) expect(res.header.location).to.endWith( - '/reset-password?errorCodes=INVALID_PASSWORD' + '/auth/reset-password?errorCodes=INVALID_PASSWORD' ) }) }) @@ -531,7 +531,7 @@ describe('auth router', () => { 'new_password' ).expect(302) expect(res.header.location).to.endWith( - '/reset-password?errorCodes=INVALID_TOKEN' + '/auth/reset-password?errorCodes=INVALID_TOKEN' ) }) @@ -545,7 +545,7 @@ describe('auth router', () => { 302 ) expect(res.header.location).to.endWith( - '/reset-password?errorCodes=TOKEN_EXPIRED' + '/auth/reset-password?errorCodes=TOKEN_EXPIRED' ) }) }) diff --git a/packages/web/components/templates/EmailLogin.tsx b/packages/web/components/templates/EmailLogin.tsx index f644974dd..4c2f0248f 100644 --- a/packages/web/components/templates/EmailLogin.tsx +++ b/packages/web/components/templates/EmailLogin.tsx @@ -45,7 +45,7 @@ export function EmailLogin(): JSX.Element { return (
- Login + Login Email @@ -111,7 +111,7 @@ export function EmailLogin(): JSX.Element { }} > Don't have an account? {' '} - + Sign up @@ -126,7 +126,7 @@ export function EmailLogin(): JSX.Element { }} > Forgot your password? {' '} - + Click here diff --git a/packages/web/components/templates/EmailSignup.tsx b/packages/web/components/templates/EmailSignup.tsx index 8c12b5b30..113e16f05 100644 --- a/packages/web/components/templates/EmailSignup.tsx +++ b/packages/web/components/templates/EmailSignup.tsx @@ -173,7 +173,7 @@ export function EmailSignup(): JSX.Element { }} > Already have an account? {' '} - + Login instead diff --git a/packages/web/components/templates/LoginForm.tsx b/packages/web/components/templates/LoginForm.tsx index c48ef75f2..9af721277 100644 --- a/packages/web/components/templates/LoginForm.tsx +++ b/packages/web/components/templates/LoginForm.tsx @@ -106,33 +106,6 @@ export function LoginForm(props: LoginFormProps): JSX.Element { /> )} -{/* - - - Use your email address to{' '} - - - Login - - {' '} - or{' '} - - - Signup - - {' '} - with your email address. - - */} - diff --git a/packages/web/locales/en/messages.ts b/packages/web/locales/en/messages.ts index 1efc879fc..8a1d2f65f 100644 --- a/packages/web/locales/en/messages.ts +++ b/packages/web/locales/en/messages.ts @@ -24,6 +24,7 @@ const errorMessages: Record = { 'error.EXPIRED_TOKEN': "Your sign up page has timed out, you'll be redirected to Google sign in page to authenticate again.", 'error.USER_EXISTS': 'User with this email exists already', + 'error.UNKNOWN': 'An unknown error occurred', } const loginPageMessages: Record = { diff --git a/packages/web/pages/confirm-email/[token].tsx b/packages/web/pages/auth/confirm-email/[token].tsx similarity index 73% rename from packages/web/pages/confirm-email/[token].tsx rename to packages/web/pages/auth/confirm-email/[token].tsx index 5a0d9754e..8a44f40b7 100644 --- a/packages/web/pages/confirm-email/[token].tsx +++ b/packages/web/pages/auth/confirm-email/[token].tsx @@ -2,14 +2,13 @@ import { useEffect, useRef, useState } from 'react' import { useRouter } from 'next/router' import { Toaster } from 'react-hot-toast' -import { applyStoredTheme } from '../../lib/themeUpdater' +import { applyStoredTheme } from '../../../lib/themeUpdater' -import { PrimaryLayout } from '../../components/templates/PrimaryLayout' +import { PrimaryLayout } from '../../../components/templates/PrimaryLayout' -import { HStack, SpanBox } from '../../components/elements/LayoutPrimitives' -import { Loader } from '../../components/templates/SavingRequest' -import { fetchEndpoint } from '../../lib/appConfig' -import { LoadingView } from '../../components/patterns/LoadingView' +import { HStack, SpanBox } from '../../../components/elements/LayoutPrimitives' +import { fetchEndpoint } from '../../../lib/appConfig' +import { LoadingView } from '../../../components/patterns/LoadingView' export default function ConfirmEmail(): JSX.Element { const authForm = useRef(null) diff --git a/packages/web/pages/auth/email-login.tsx b/packages/web/pages/auth/email-login.tsx new file mode 100644 index 000000000..aadf9913f --- /dev/null +++ b/packages/web/pages/auth/email-login.tsx @@ -0,0 +1,15 @@ +import { PageMetaData } from '../../components/patterns/PageMetaData' +import { ProfileLayout } from '../../components/templates/ProfileLayout' +import { EmailLogin } from '../../components/templates/EmailLogin' + +export default function EmailLoginPage(): JSX.Element { + return ( + <> + + + + +
+ + ) +} diff --git a/packages/web/pages/auth/email-signup.tsx b/packages/web/pages/auth/email-signup.tsx new file mode 100644 index 000000000..819fe0b16 --- /dev/null +++ b/packages/web/pages/auth/email-signup.tsx @@ -0,0 +1,15 @@ +import { PageMetaData } from '../../components/patterns/PageMetaData' +import { ProfileLayout } from '../../components/templates/ProfileLayout' +import { EmailSignup } from '../../components/templates/EmailSignup' + +export default function EmailRegistrationPage(): JSX.Element { + return ( + <> + + + + +
+ + ) +} diff --git a/packages/web/pages/forgot-password.tsx b/packages/web/pages/auth/forgot-password.tsx similarity index 66% rename from packages/web/pages/forgot-password.tsx rename to packages/web/pages/auth/forgot-password.tsx index 3ad70ee63..d1ee0a922 100644 --- a/packages/web/pages/forgot-password.tsx +++ b/packages/web/pages/auth/forgot-password.tsx @@ -1,10 +1,10 @@ -import { PageMetaData } from '../components/patterns/PageMetaData' -import { ProfileLayout } from '../components/templates/ProfileLayout' -import { EmailResetPassword } from '../components/templates/EmailResetPassword' +import { PageMetaData } from '../../components/patterns/PageMetaData' +import { ProfileLayout } from '../../components/templates/ProfileLayout' +import { EmailResetPassword } from '../../components/templates/EmailResetPassword' import { useEffect } from 'react' import { useRouter } from 'next/router' import toast, { Toaster } from 'react-hot-toast' -import { showSuccessToast } from '../lib/toastHelpers' +import { showSuccessToast } from '../../lib/toastHelpers' export default function ForgotPassword(): JSX.Element { const router = useRouter() @@ -21,7 +21,7 @@ export default function ForgotPassword(): JSX.Element { return ( <> - + -
+
) } diff --git a/packages/web/pages/auth/reset-password.tsx b/packages/web/pages/auth/reset-password.tsx new file mode 100644 index 000000000..f2dff55ba --- /dev/null +++ b/packages/web/pages/auth/reset-password.tsx @@ -0,0 +1,15 @@ +import { PageMetaData } from '../../components/patterns/PageMetaData' +import { ProfileLayout } from '../../components/templates/ProfileLayout' +import { EmailResetPassword } from '../../components/templates/EmailResetPassword' + +export default function EmailRegistrationPage(): JSX.Element { + return ( + <> + + + + +
+ + ) +} diff --git a/packages/web/pages/auth/verify-email.tsx b/packages/web/pages/auth/verify-email.tsx new file mode 100644 index 000000000..0606e88df --- /dev/null +++ b/packages/web/pages/auth/verify-email.tsx @@ -0,0 +1,12 @@ +import { PageMetaData } from '../../components/patterns/PageMetaData' +import { VerifyEmail } from '../../components/templates/VerifyEmail' + +export default function VerifyEmailPage(): JSX.Element { + return ( + <> + + +
+ + ) +} diff --git a/packages/web/pages/email-login.tsx b/packages/web/pages/email-login.tsx deleted file mode 100644 index 6011118f0..000000000 --- a/packages/web/pages/email-login.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { PageMetaData } from '../components/patterns/PageMetaData' -import { ProfileLayout } from '../components/templates/ProfileLayout' -import { EmailLogin } from '../components/templates/EmailLogin' - -export default function EmailLoginPage(): JSX.Element { - return ( - <> - - - - -
- - ) -} - -// export default function EmailLogin(): JSX.Element { -// const [errorMessage, setErrorMessage] = useState( -// undefined -// ) -// const [message, setMessage] = useState(undefined) -// const router = useRouter() - -// useEffect(() => { -// if (!router.isReady) return -// const errorCode = parseErrorCodes(router.query) -// const errorMsg = errorCode -// ? formatMessage({ id: `error.${errorCode}` }) -// : undefined -// setErrorMessage(errorMsg) - -// const message = router.query.message -// ? formatMessage({ id: `login.${router.query.message}` }) -// : undefined -// setMessage(message) -// }, [router.isReady, router.query]) - -// return ( -// -// {message && {message}} -//

Email Login

-// -//
-// -// -//
-//
-// -// -//
-// {errorMessage && {errorMessage}} -// -// -//
-// ) -// } diff --git a/packages/web/pages/email-reset-password.tsx b/packages/web/pages/email-reset-password.tsx deleted file mode 100644 index 88b0e4b8c..000000000 --- a/packages/web/pages/email-reset-password.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { PageMetaData } from '../components/patterns/PageMetaData' -import { ProfileLayout } from '../components/templates/ProfileLayout' -import { EmailResetPassword } from '../components/templates/EmailResetPassword' - -export default function EmailRegistrationPage(): JSX.Element { - return ( - <> - - - - -
- - ) -} diff --git a/packages/web/pages/email-signup.tsx b/packages/web/pages/email-signup.tsx deleted file mode 100644 index 5fa84d37b..000000000 --- a/packages/web/pages/email-signup.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { PageMetaData } from '../components/patterns/PageMetaData' -import { ProfileLayout } from '../components/templates/ProfileLayout' -import { EmailSignup } from '../components/templates/EmailSignup' - -export default function EmailRegistrationPage(): JSX.Element { - return ( - <> - - - - -
- - ) -} diff --git a/packages/web/pages/verify-email.tsx b/packages/web/pages/verify-email.tsx deleted file mode 100644 index c25d7dff4..000000000 --- a/packages/web/pages/verify-email.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { PageMetaData } from '../components/patterns/PageMetaData' -import { VerifyEmail } from '../components/templates/VerifyEmail' - -export default function VerifyEmailPage(): JSX.Element { - return ( - <> - - -
- - ) -}