Open Closed

How to implement Passwordless authentication for angular? #7124


User avatar
0
BOMSDevTeam created
  • ABP Framework version: v8.1.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Auth Server Separated (for Angular): yes

Hello

I am trying to implement the Passwordless solution, following the guidelines provided at https://community.abp.io/posts/implementing-passwordless-authentication-with-asp.net-core-identity-c25l8koj. It is for MVC application . I need to implement for angular. I have used separated auth server. Please provide more detail for passwordless authentication and generate url for angular application.

Thank you


3 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hello,

    please check similar issue https://support.abp.io/QA/Questions/6240/Angular-Passwordless if it helps you.

    thanks

  • User Avatar
    0
    BOMSDevTeam created

    Hello

    https://community.abp.io/posts/how-to-add-a-custom-grant-type-in-openiddict.-6v0df94z

    I am trying the above solution but it is not working because I am using a separate auth server (openIddict). Please provide any proper solution for Passwordless authentication. My requirement is to first generate a passwordless login url and send it to the user in mail inbox and the user clicks on the passwordless login url then redirects to angular application with authentication.

    thanks

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This article also applies to Angular UI https://community.abp.io/posts/implementing-passwordless-authentication-with-asp.net-core-identity-c25l8koj

    You just need to redirect to the angular website in the publicclassPasswordlessController.

    For example:

    using System;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Volo.Abp.AspNetCore.Mvc;
    using Volo.Abp.Identity;
    using Volo.Abp.Identity.AspNetCore;
    
    namespace PasswordlessAuthentication.Web.Controllers
    {
        public class PasswordlessController : AbpController
        {
            protected IdentityUserManager UserManager { get; }
    
            protected AbpSignInManager SignInManager { get; }
    
            public PasswordlessController(IdentityUserManager userManager, AbpSignInManager signInManager)
            {
                UserManager = userManager;
                SignInManager = signInManager;
            }
    
            public virtual async Task<IActionResult> Login(string token, string userId)
            {
                var user = await UserManager.FindByIdAsync(userId);
    
                var isValid = await UserManager.VerifyUserTokenAsync(user, "PasswordlessLoginProvider", "passwordless-auth", token);
                if (!isValid)
                {
                    throw new UnauthorizedAccessException("The token " + token + " is not valid for the user " + userId);
                }
    
                await UserManager.UpdateSecurityStampAsync(user);
    
                await SignInManager.SignInAsync(user, isPersistent: false);
    
                var ngAppUrl = "http://localhost:4200/account/login"
                return Redirect(ngAppUrl);
            }
        }
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15