-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from chrishiguto/feature/add-unauth-routes-an…
…d-more-customization feat: add unauth routes and more customization to rockets provider an…
- Loading branch information
Showing
10 changed files
with
217 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
37 changes: 37 additions & 0 deletions
37
packages/react-navigation/src/components/ForgotPasswordRoute.tsx
This file contains 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,37 @@ | ||
import React from 'react'; | ||
|
||
import { Navigate } from 'react-router'; | ||
import { useAuth } from '@concepta/react-auth-provider'; | ||
import { AuthModule } from '@concepta/react-material-ui/'; | ||
import { toast } from 'react-toastify'; | ||
|
||
type ForgotPasswordRouteProps = { | ||
home: string; | ||
}; | ||
|
||
const ForgotPasswordRoute = ({ home }: ForgotPasswordRouteProps) => { | ||
const { accessToken: authAccessToken } = useAuth(); | ||
|
||
const accessToken = authAccessToken ?? localStorage.getItem('accessToken'); | ||
|
||
if (accessToken) { | ||
return <Navigate to={home} replace />; | ||
} | ||
|
||
return ( | ||
<AuthModule | ||
route="forgotPassword" | ||
moduleProps={{ | ||
Check failure on line 24 in packages/react-navigation/src/components/ForgotPasswordRoute.tsx
|
||
signInPath: '/sign-in', | ||
onSuccess: () => toast.success('Success!'), | ||
onError: (error: any) => | ||
toast.error( | ||
error?.response?.data?.message || | ||
'An error has occurred. Please try again later or contact support for assistance.', | ||
), | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default ForgotPasswordRoute; |
37 changes: 37 additions & 0 deletions
37
packages/react-navigation/src/components/ResetPasswordRoute.tsx
This file contains 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,37 @@ | ||
import React from 'react'; | ||
|
||
import { Navigate } from 'react-router'; | ||
import { useAuth } from '@concepta/react-auth-provider'; | ||
import { AuthModule } from '@concepta/react-material-ui/'; | ||
import { toast } from 'react-toastify'; | ||
|
||
type ResetPasswordRouteProps = { | ||
home: string; | ||
}; | ||
|
||
const ResetPasswordRoute = ({ home }: ResetPasswordRouteProps) => { | ||
const { accessToken: authAccessToken } = useAuth(); | ||
|
||
const accessToken = authAccessToken ?? localStorage.getItem('accessToken'); | ||
|
||
if (accessToken) { | ||
return <Navigate to={home} replace />; | ||
} | ||
|
||
return ( | ||
<AuthModule | ||
route="resetPassword" | ||
moduleProps={{ | ||
Check failure on line 24 in packages/react-navigation/src/components/ResetPasswordRoute.tsx
|
||
signInPath: '/sign-in', | ||
onSuccess: () => toast.success('Success!'), | ||
onError: (error: any) => | ||
toast.error( | ||
error?.response?.data?.message || | ||
'An error has occurred. Please try again later or contact support for assistance.', | ||
), | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default ResetPasswordRoute; |
This file contains 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 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 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,37 @@ | ||
import React from 'react'; | ||
|
||
import { Navigate } from 'react-router'; | ||
import { useAuth } from '@concepta/react-auth-provider'; | ||
import { AuthModule } from '@concepta/react-material-ui/'; | ||
import { toast } from 'react-toastify'; | ||
|
||
type SignUpRouteProps = { | ||
home: string; | ||
}; | ||
|
||
const SignUpRoute = ({ home }: SignUpRouteProps) => { | ||
const { accessToken: authAccessToken } = useAuth(); | ||
|
||
const accessToken = authAccessToken ?? localStorage.getItem('accessToken'); | ||
|
||
if (accessToken) { | ||
return <Navigate to={home} replace />; | ||
} | ||
|
||
return ( | ||
<AuthModule | ||
route="signUp" | ||
moduleProps={{ | ||
Check failure on line 24 in packages/react-navigation/src/components/SignUpRoute.tsx
|
||
signInPath: '/sign-in', | ||
onSuccess: () => toast.success('Success!'), | ||
onError: (error: any) => | ||
toast.error( | ||
error?.response?.data?.message || | ||
'An error has occurred. Please try again later or contact support for assistance.', | ||
), | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default SignUpRoute; |
This file contains 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