-
Notifications
You must be signed in to change notification settings - Fork 1
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
Do not send user email when setting up TOTP as 2nd factor #104
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src: (context: AuthContext<any>, event: AuthMachineEvent) => { | ||
const arg: Record<string, any> = { | ||
method: "totp", | ||
}; | ||
|
||
if (hasValue((<TotpCodeSubmitEvent>event).totpCode)) { | ||
arg.totpCode = (<TotpCodeSubmitEvent>event).totpCode; | ||
} | ||
|
||
// API only requires email/emailOrUsername when logging in via first factor | ||
if (!context.isSecondFactor) { | ||
if (hasValue(context.user.email)) { | ||
arg.email = context.user.email; | ||
} else if (hasValue(context.user.emailOrUsername)) { | ||
arg.emailOrUsername = context.user.emailOrUsername; | ||
} | ||
|
||
arg.redirect = false; | ||
} | ||
|
||
return callUserfront({ | ||
// Should ALWAYS be Userfront.login here | ||
method: "login", | ||
args: [ | ||
{ | ||
method: "totp", | ||
totpCode: (<TotpCodeSubmitEvent>event).totpCode, | ||
email: context.user.email, | ||
redirect: false, | ||
}, | ||
], | ||
}), | ||
args: [arg], | ||
}); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The email
/emailOrUsername
check has been added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Published version 1.1.0-alpha.3 to npm. |
Normal
Closes DEV-1046
This will check for
email
oremailOrUsername
only if TOTP is being set up as a first factor.I also removed the password instructions on the login form i.e.