prevent users without confirmed email from logging in ASP.Net MVC with Identity 2

前端 未结 6 1153
遥遥无期
遥遥无期 2020-12-29 08:28

In microsoft Identity 2 there is ability to users can confirm there email addresses I downloaded Identity 2 sample project from here in this project there isn\'t any differ

6条回答
  •  心在旅途
    2020-12-29 08:57

    I would let the admin create the user without any password. The email with link should go to the user. The user then is directed to SetPassword page to set new password. This way no one can access the user account unless he confirms and sets the password.

    Call CreateAsync without the password

    var adminresult = await UserManager.CreateAsync(user);
    

    Redirect admin to new custom view saying something like "Email is sent to user"

    @{
        ViewBag.Title = "New User created and Email is Sent";
    }
    

    @ViewBag.Title.

    The New User has to follow the instructions to complete the user creation process.

    Please change this code to register an email service in IdentityConfig to send an email.

提交回复
热议问题