Skip to content

Commit

Permalink
Merge pull request #88 from nicolelim02/feat/users
Browse files Browse the repository at this point in the history
Fix email verification routes
  • Loading branch information
ruiqi7 authored Oct 28, 2024
2 parents 2d59d81 + 593c450 commit 345851a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
8 changes: 4 additions & 4 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ function App() {
<Route index element={<Navigate to="/auth/login" />} />
<Route path="signup" element={<SignUp />} />
<Route path="login" element={<LogIn />} />
<Route
path="verifyEmail/:userId?"
element={<EmailVerification />}
/>
<Route path="verify-email">
<Route index element={<EmailVerification />} />
<Route path=":userId" element={<EmailVerification />} />
</Route>
<Route path="forget-password" element={<ForgetPassword />} />
<Route path="*" element={<Navigate to="/auth/login" />} />
</Route>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const AuthProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
})
.then(() => userClient.post("users/send-verification-email", { email }))
.then((res) => {
navigate(`/auth/verifyEmail/${res.data.data.id}`);
navigate(`/auth/verify-email/${res.data.data.id}`);
})
.catch((err) => {
setUser(null);
Expand All @@ -88,7 +88,7 @@ const AuthProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
})
.catch((err) => {
if (err.response?.data.message === "User not verified.") {
navigate(`/auth/verifyEmail`);
navigate(`/auth/verify-email`);
}
setUser(null);
toast.error(err.response?.data.message || err.message);
Expand Down
10 changes: 1 addition & 9 deletions frontend/src/pages/EmailVerification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const EmailVerification: React.FC = () => {
onChange={(e) => setEmail(e.target.value)}
slotProps={{
input: {
endAdornment: <Button onClick={handleSendEmail}>Send</Button>,
endAdornment: <Button onClick={handleSendEmail}>Resend</Button>,
},
}}
/>
Expand All @@ -93,14 +93,6 @@ const EmailVerification: React.FC = () => {
spacing={2}
sx={(theme) => ({ marginTop: theme.spacing(4) })}
>
<Button
fullWidth
variant="contained"
color="secondary"
onClick={handleSendEmail}
>
Resend
</Button>
<Button fullWidth variant="contained" onClick={handleVerifyAcc}>
Verify
</Button>
Expand Down

0 comments on commit 345851a

Please sign in to comment.