-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Debug hints on Account confirmation and password recovery #15830
Comments
|
I followed this tutorial on .net core 3.1 and whatever I do the email is not sending. I debugged the application and it really execute the Task Execute method but, I did not received any using forgot password and verify account. I also checked the SendGrid stats it's always 0. Anyone can enlighten me with this would be much appreciated. |
The issue is twofold:
If you debug and break on the email send, you should be able to get the email to send. But if you just run it, the thread will end before the request is sent due to the missing await. This code is working for me and includes the missing awaits as well as a check for the response to be successful:
|
@ardalis do you want to open an issue on the template? |
For me, password reset emails work perfectly but the confirmation message is never sent. I have a breakpoint in the start of the SendEmailAsync method and it's hit every time for password reset but never for confirmation. |
I actually placed a break point in SendEmailAsync on the call to the Execute method, on the construction of the SendGridClient, and on "return client.SendEmailAsync();". None of these are being called... I have checked to make sure that this: |
Ok, I figured out my issue...but this very well could be a bug.If you add an external authentication method (i.e. Microsoft Authentication), when you click on register and are presented with the registration page you can register with the external authentication method (in my case Microsoft Authentication) as opposed to creating a local account. If you use external authentication as your registration method, then the email confirmation process is completely bypassed/ignored.Is this "as by design" or is this a bug? |
Forgot to mention... even though the email confirmation process is never invoked (i.e. SendEmailAsync is never called) when you register using an external authorization as opposed to local, upon completing the external authentication process successfully it will place the user back on the "Register Confirmation" page. So, either it should "auto confirm" upon success of the external authentication process and proceed to the confirmation complete page =or= it should invoke the SendEmailAsync method. Any thoughts are appreciated! :) |
I worked the exercise a second time with success. Here are the details of the entire exercise on Stack Overflow. https://stackoverflow.com/questions/60617079/core3-react-confirmation-email-not-sent |
Well, I am using SendGrid and am assuming you were still using your exchange server when you worked through it again? I too started from scratch (starting with the very beginning of this example and then adding the external authentication afterwards). So, there was no 3.0 to 3.1 back and fourth in my case. Just the example, SendGrid, and Microsoft Authentication. Maybe I missed a step, but I already started a new project from scratch and everything so far looks identical...will pickup on this tomorrow and see if the next version I am working through works. Will let you know how my second pass goes. |
Solve one problem at a time. |
Read this, learn to scaffold, then debug. https://stackoverflow.com/questions/60739857/how-to-customise-or-style-the-auth-ux-in-dotnet-core-3 |
Thank you Peter! The Scaffold path was exactly what I needed. I am ramping back up with all of the ASP/Razor/NET Core Web Application stuff that has changed over the past 7-8 years (I was primarily writing network drivers during that time). Either case, I went ahead and generated all of the RTL source for Identity and I believe I now know what is the issue with External Authentication.
What I believe is happening is that the SignIn.RequireConfirmedAccount is true and it bypasses sending any confirmation email and just redirects the user directly to the RegisterConfirmation page. This is why (I believe) using external authentication as your registration method will dump the user to the "Registration Confirmation" page stating an email has been sent but in reality it never gets sent.
And then add it back towards the end of that conditional branch:
Then it would send the email & push the user to the Register Confirmation page. Any thoughts on this? (Good/Bad Idea)? Either case, thank you for your tips/guidance! Once I ran through the Scaffold Identity article, everything "clicked into place"... Cheers, Noel |
For anyone else who finds themselves reading through these threads here are some additional modifications to the above changes to fix some issues with whether the user should be logged in or not during the registration process. I added an additional call to sign out the externally authenticated user in order to assure that it doesn't keep the user logged in while still waiting for authentication:
Additionally, in the same ExternalLogin.cshtml.cs file I also modified the OnGetCallbackAsync method with this:
While I am sure there are much better ways to handle user login states, this is just a heads up for anyone else that ran into similar issues (starting with the issue of email confirmations for users that register with an external authentication source). The two above changes assures that the user is not considered "logged in" until they have confirmed their email address as well as assures that if the user returns without confirming it will see they have registered but not confirmed and will just display the "Register Confirmation" page. Anyway, thank you Peter for pointing me in the right direction... going to start reading up on additional materials regarding user authentication states and management of them from page to page (etc). |
Where can we possibly find latest version typical implementation examples of ASP.Net Core Identity razor pages? ASP.Net Core 3.1 Identity all pages in Areas/Identity for example.. New learners need those examples but things are changing fast and teacher candidates keep being students in this fast change. |
Please add the fact that in order for a forgot password email to be sent the user must
#1
exist in the DB and#2
the user must have EmailConfirmed Set to True. Also, if that is not the case there is no indication of that via the web interface, the email is never attempted to be sent.I would like like to suggest that if env.IsDevelopment() is true that feedback be provided these requirments. - Thx
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: