-
Notifications
You must be signed in to change notification settings - Fork 4
Integrate end-to-end forgot/reset password and logout flows (RHF + Zod, TanStack Query) #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SepidehShahbazi
merged 14 commits into
feat/29-auth-pages-integration
from
feat/29-forgot-reset-password-integration
Oct 9, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d1bc820
feat(auth): use RHF + Zod on forgot/reset password; integrate with ba…
SepidehShahbazi f7b19f0
feat(forms): add RHF+Zod form hooks
SepidehShahbazi 03ef70f
feat(auth): introduce data hooks (forgot/reset) and update useSignOut…
SepidehShahbazi 61721cf
feat(components): add reusable PasswordValidation and integrate it in…
SepidehShahbazi e6ce031
feat(icons): add new React icon components
SepidehShahbazi 3eb644a
fix(api): reject password reset when new password matches current
SepidehShahbazi 9f84a97
refactor(middleware): use updated publicRoutes including /password/fo…
SepidehShahbazi e1c6581
chore: small cleanups for app-wide consistency
SepidehShahbazi 393690a
Merge pull request #57 from bluewave-labs/dev
mahid797 a2dec8d
Merge branch 'feat/29-auth-pages-integration' of https://github.com/b…
SepidehShahbazi e9d31da
Merge branch 'feat/29-auth-pages-integration' of https://github.com/b…
SepidehShahbazi 143cf15
refactor(query): add canonical mutationKeys and apply to auth mutations
SepidehShahbazi f88b02b
refactor(app): update auth forms and React Query cache handling
SepidehShahbazi 80e5f16
Merge branch 'feat/29-forgot-reset-password-integration' of https://g…
SepidehShahbazi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { FC, SVGProps } from 'react'; | ||
|
||
type IconColor = 'error' | 'success' | 'disabled' | 'outline' | 'primaryOutline'; | ||
|
||
const colorMap: Record<IconColor, string> = { | ||
error: '#F04438', | ||
success: '#067647', | ||
disabled: '#D0D5DD', | ||
outline: '#344054', | ||
primaryOutline: '#1570ef', | ||
}; | ||
|
||
interface CheckCircleIconProps extends SVGProps<SVGSVGElement> { | ||
width?: number; | ||
height?: number; | ||
color?: IconColor; | ||
} | ||
|
||
/** | ||
* A reusable SVG icon component for rendering an icon. | ||
* | ||
* @param {number} [width=24] - The width of the icon in pixels. Optional. | ||
* @param {number} [height=24] - The height of the icon in pixels. Optional. | ||
* @param {IconColor} [color='disabled'] - The stroke color of the icon. Accepts any valid CSS color value. Optional. | ||
* @param {SVGProps<SVGSVGElement>} props - Additional SVG props such as `className`, `style`, or custom attributes. | ||
* | ||
* @returns {JSX.Element} A scalable vector graphic (SVG) element representing the icon. | ||
*/ | ||
|
||
const CheckCircleIcon: FC<CheckCircleIconProps> = ({ | ||
width = 24, | ||
height = 24, | ||
color = 'disabled', | ||
...props | ||
}) => { | ||
const isOutline = color === 'outline'; | ||
const isPrimaryOutline = color === 'primaryOutline'; | ||
const fillColor = isOutline || isPrimaryOutline ? 'none' : colorMap[color]; | ||
const strokeColor = isOutline | ||
? colorMap['outline'] | ||
: isPrimaryOutline | ||
? colorMap['primaryOutline'] | ||
: 'none'; | ||
|
||
return ( | ||
<svg | ||
width={width} | ||
height={height} | ||
viewBox='0 0 24 24' | ||
fill='none' | ||
xmlns='http://www.w3.org/2000/svg' | ||
aria-label='Check Circle Icon' | ||
role='img' | ||
{...props} | ||
> | ||
<circle | ||
cx='12' | ||
cy='12' | ||
r='11' | ||
fill={fillColor} | ||
stroke={strokeColor} | ||
strokeWidth={isOutline || isPrimaryOutline ? 2 : 0} | ||
/> | ||
|
||
<path | ||
d='M8 12L10.5 14.5L16 9' | ||
stroke={ | ||
isOutline ? colorMap['outline'] : isPrimaryOutline ? colorMap['primaryOutline'] : 'white' | ||
} | ||
strokeWidth='2' | ||
strokeLinecap='round' | ||
strokeLinejoin='round' | ||
/> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default CheckCircleIcon; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { FC, SVGProps } from 'react'; | ||
|
||
type IconColor = 'error' | 'success' | 'disabled' | 'outline'; | ||
|
||
const colorMap: Record<IconColor, string> = { | ||
error: '#F04438', | ||
success: '#067647', | ||
disabled: '#D0D5DD', | ||
outline: '#344054', | ||
}; | ||
|
||
interface XCircleIconProps extends SVGProps<SVGSVGElement> { | ||
width?: number; | ||
height?: number; | ||
color?: IconColor; | ||
} | ||
|
||
/** | ||
* A reusable SVG icon component for rendering an icon. | ||
* | ||
* @param {number} [width=24] - The width of the icon in pixels. Optional. | ||
* @param {number} [height=24] - The height of the icon in pixels. Optional. | ||
* @param {IconColor} [color='disabled'] - The stroke color of the icon. Accepts any valid CSS color value. Optional. | ||
* @param {SVGProps<SVGSVGElement>} props - Additional SVG props such as `className`, `style`, or custom attributes. | ||
* | ||
* @returns {JSX.Element} A scalable vector graphic (SVG) element representing the icon. | ||
*/ | ||
|
||
const XCircleIcon: FC<XCircleIconProps> = ({ | ||
width = 24, | ||
height = 24, | ||
color = 'disabled', | ||
...props | ||
}) => { | ||
const isOutline = color === 'outline'; | ||
const fillColor = isOutline ? 'none' : colorMap[color]; | ||
const strokeColor = isOutline ? colorMap['outline'] : colorMap[color]; | ||
|
||
return ( | ||
<svg | ||
width={width} | ||
height={height} | ||
viewBox='0 0 24 24' | ||
fill={fillColor} | ||
xmlns='http://www.w3.org/2000/svg' | ||
aria-label='X Circle Icon' | ||
role='img' | ||
{...props} | ||
> | ||
<circle | ||
cx='12' | ||
cy='12' | ||
r='11' | ||
fill={fillColor} | ||
stroke={strokeColor} | ||
strokeWidth={isOutline ? 2 : 0} | ||
/> | ||
<path | ||
d='M15 9L9 15M9 9L15 15' | ||
stroke={isOutline ? colorMap['outline'] : 'white'} | ||
strokeWidth='2' | ||
strokeLinecap='round' | ||
strokeLinejoin='round' | ||
/> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default XCircleIcon; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
|
||
import NextLink from 'next/link'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
import { Button, FormInput } from '@components'; | ||
|
||
import { useForgotPasswordMutation } from '@/app/(client)/hooks/data'; | ||
import { useForgotPasswordForm, useFormSubmission } from '@/app/(client)/hooks/forms'; | ||
import { Form } from '@/shadcn-ui'; | ||
|
||
export default function ForgotPasswordForm() { | ||
const router = useRouter(); | ||
const forgotPasswordMutation = useForgotPasswordMutation(); | ||
const form = useForgotPasswordForm(); | ||
|
||
const { | ||
getValues, | ||
formState: { isValid }, | ||
} = form; | ||
|
||
const { loading, handleSubmit, toast } = useFormSubmission({ | ||
mutation: forgotPasswordMutation, | ||
getVariables: () => getValues(), | ||
validate: () => isValid, | ||
onSuccess: async (res) => { | ||
// Dev-only: jump straight to reset with token | ||
if (res?.token) { | ||
router.replace(`/password/reset?token=${encodeURIComponent(res.token)}`); | ||
} else { | ||
// Fallback: a dev page that explains what's happening | ||
router.replace('/password/reset?dev=1'); | ||
} | ||
}, | ||
onError: (err) => { | ||
const message = | ||
err instanceof Error && err.message | ||
? err.message | ||
: 'Could not process password reset request.'; | ||
toast.showToast({ message, variant: 'error' }); | ||
}, | ||
skipDefaultToast: true, | ||
}); | ||
|
||
return ( | ||
<> | ||
<div className='flex flex-col items-center gap-4'> | ||
<h1 className='h1'>Forgot password?</h1> | ||
<p className='body2'>Enter your account email to continue.</p> | ||
</div> | ||
<Form {...form}> | ||
<form | ||
onSubmit={handleSubmit} | ||
className='min-w-[25em]' | ||
> | ||
<div className='mb-10 flex flex-col gap-5'> | ||
<FormInput | ||
control={form.control} | ||
name='email' | ||
label='Email' | ||
type='email' | ||
placeholder='[email protected]' | ||
/> | ||
</div> | ||
<div> | ||
<Button | ||
type='submit' | ||
fullWidth | ||
disabled={!isValid || loading} | ||
loading={loading} | ||
loadingText='Processing...' | ||
> | ||
Reset password | ||
</Button> | ||
</div> | ||
</form> | ||
</Form> | ||
<NextLink href='/login'>← Back to login</NextLink> | ||
</> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.