-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a219fd
commit ecde1cf
Showing
10 changed files
with
109 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
<head> | ||
<title>2FA Recovery</title> | ||
</head> | ||
<body> | ||
<h1>Two-Factor Authentication Recovery</h1> | ||
<p>Hello, {{name}}</p> | ||
<p>To recover your account, please click on the link below:</p> | ||
<a | ||
href='{{baseUrl}}/2fa/confirm-recovery?email={{email}}&code={{code}}' | ||
>Recover Account</a> | ||
<p>If you did not request this, please ignore this email.</p> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export enum HandlebarsTemplate { | ||
PASSWORD_RESET_CODE = 'password-reset-code', | ||
WELCOME = 'welcome', | ||
EMAIL_CONFIRMATION = 'email-confirmation' | ||
EMAIL_CONFIRMATION = 'email-confirmation', | ||
CONFIRM_RECOVERY = 'confirm-2fa-recovery' | ||
} |
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,40 @@ | ||
import { useState, useEffect } from 'react' | ||
import { useNavigate, useSearchParams } from 'react-router-dom' | ||
import { useTwoFactorAuthHook } from '../../hooks/use2FA' | ||
import { toast } from 'react-toastify' | ||
|
||
export const Disable2FAView = () => { | ||
const navigate = useNavigate() | ||
const [searchParams] = useSearchParams() | ||
const [message, setMessage] = useState('') | ||
|
||
const { disable2FA, isLoading } = useTwoFactorAuthHook() | ||
|
||
useEffect(() => { | ||
const email = searchParams.get('email') | ||
const code = searchParams.get('code') | ||
|
||
if (!email || !code) { | ||
navigate('/login') | ||
} else { | ||
disable2FA({ email, code }) | ||
.then(() => { | ||
const msg = | ||
'Your 2fa was disabled, please log-in and enable 2fa again.' | ||
toast.success(msg) | ||
setMessage(msg) | ||
setTimeout(() => navigate('/login'), 3000) | ||
}) | ||
.catch((error: any) => { | ||
console.error('Error disabling 2FA:', error) | ||
navigate('/login') | ||
}) | ||
} | ||
}, [disable2FA, navigate, searchParams]) | ||
|
||
return ( | ||
<div> | ||
{isLoading ? <p>{message}</p> : <p>Disabling 2FA, please wait...</p>} | ||
</div> | ||
) | ||
} |
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