Skip to main content

Posts

Showing posts with the label Asp.Net Core Identity

Part-3 | Asp.Net Core Identity Series[.NET 7] | Sending Two-Factor Authentication(2FA) Code To Email

The main objectives of this article are: Sending Two-Factor Authentication(2FA) Code To Email Enable Email 2FA: In Asp.Net Core Identity application to enable email Two-Factor Authentication, make sure our 'AspNetUser' table following fields has appropriate data: Email - Should not be empty or null EmailConfrimed - must be true TwoFactorEnabled - must be true. Now if we try to login into our application we can see a page to enter the 2FA code like below Send Two-Factor Authentication(2FA) Code To Email: Now let's update the code in 'OnGetAsync()' method in 'Areas/Identity/Pages/Account/LoginWith2faModel.cshtml.cs' as below. Areas/Identity/Pages/Account/LoginWith2faModel.cshtml.cs: public async Task<IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null) { // Ensure the user has gone through the username & password screen first var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); if (user == null) { throw ne

Part-2 | Asp.Net Core Identity Series[.NET 7] | Registration Email Confirmation

The main objectives of this article are: Use SendGrid Email Service. Implement Email Confirmation For User Registration Send Grid: SendGrid is a third-party email provider from which we deal with 'send' and 'receive' operations of email to our application. SendGrid SMTP(Simple Mail Transfer Protocol) provider for email transfer. SendGrid also provides SendGrid .Net NuGet package that provides easy configuration to any .NET application. So to use the SendGrid SMTP we need 'Auth Key', 'From Email'. So let's register into SendGrid. The following are the steps to register and generate the API key in SendGrid: (Step 1) Go to SendGrid's official website at 'https://sendgrid.com/'. Next do SingUp. (Step 2) Now login in to the SendGrid website, then under the left-hand side menu go to the 'Settings' ==> 'Sender Authentication'. At 'Single Sender Verification' click on the 'Get Started' button. (Step 3) Let'

Part -1 | Asp.Net Core Identity Series[.NET 7] Introduction & Project Setup

The main objectives of the article are: Introduction On Asp.NET Core Identity Create Razor Page Application(.NET 7) With Asp.Net Core Identity Generate Asp.Net Core Identity Tables Default Registration & Login Asp.Net Core Identity: Asp.Net Core Identity is a built-in login functionality library that supports authentication of all different .NET applications like "MVC", "Razor Pages", "And Blazor Server". Provides rich authentication UI pages which are customizable as well. Adoptable for external authentication providers like 'Google', 'Facebook', 'Outlook', etc. Can be integrated with other authentication like 'IdentityServer4', 'Azure Active Directory', 'Azure Active Directory B2C(Azure AD B2C)'. Create A .NET7 Razor Page Application With Individual Authentication: Let's create .NET7 Razor Page application with individual authentication to accomplish our demo. We can use either Visual Studio 202