forked from geolba/tethys.backend
- added 2fa authentication during login. see resources/js/Pages/Auth/login.vue
- added validate() method inside app/Srvices/TwoFactorProvider.ts - added twoFactorChallenge() method inside app/Controllers/Http/Auth/AuthController.ts for logging in via 2fa-code
This commit is contained in:
parent
b2dce0259a
commit
f828ca4491
7 changed files with 233 additions and 84 deletions
|
@ -105,7 +105,7 @@ class TwoFactorAuthProvider {
|
|||
public async enable(user: User, token: string): Promise<boolean> {
|
||||
const isValid = verifyToken(user.twoFactorSecret as string, token, 1);
|
||||
if (!isValid) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
user.state = TotpState.STATE_ENABLED;
|
||||
if (await user.save()) {
|
||||
|
@ -113,6 +113,14 @@ class TwoFactorAuthProvider {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async validate(user: User, token: string): Promise<boolean> {
|
||||
const isValid = verifyToken(user.twoFactorSecret as string, token, 1);
|
||||
if (isValid) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default new TwoFactorAuthProvider();
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue