-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
App Requirement: require confirmed email before user can login.
When you require a confirmed email in Startup.cs, checking whether the email is confirmed or not makes little sense until the POST username and pwd match what is in the DB.
The current flow for login violates this because PasswordSignInAsync calls PreSignInCheck prior to CheckPasswordAsync, an order which makes sense only for checking LockOut but not for email confirmation. PreSignInCheck will return SignInResult.NotAllowed for an unconfirmed email.
This flow makes it unnatural to fulfil the following likely scenario:
-User registers and an email is sent to him. He never receives this email or forgets to confirm it.
-He tries nevertheless to login, and enters the correct credentials .
-Since he entered the correct credentials, we can reveal to him that he should first confirm his email before we persist the cookie and we could propose him to resend a confirmation email. This flow will be safer than the one in the docs because the user entered the correct credentials (hence confirming his identity)
I tried to override PasswordSignInAsync but I hit SignInOrTwoFactorAsync, which is private.
The more natural way to avoid unnecessary code checks would be something around the following for
CheckPasswordSignInAsync
user IsLockedOut?
Yes-->NotAllowed
No-->Continue
UserName and Password Match?
Yes -->EmailConfirmed?
-->Yes-->Success
-->No-->result="EmailNotConfirmedYet"
No--> LockoutIncrement
PhoneNumber confirmation not mentioned. Unfortunatly the SignInResult may need to be extended to become more granular such that NotAllowed becomes split into
--UnconfirmedEmail
--UnconfirmedPhone