Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Config Identity #212


User avatar
0
behiunforgiven created

How can I config Identity with "ApplicationUserManager" and customize "UserValidator" and "PasswordValidator" and ...?


6 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    In module-zero startup template, you have UserManager class (<a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.Core/Users/UserManager.cs">https://github.com/aspnetboilerplate/mo ... Manager.cs</a>). You can override it's methods to change behaviour.

  • User Avatar
    0
    behiunforgiven created

    You are right , but "UserValidator" is not in override methods,

    How can I override it?

  • User Avatar
    0
    behiunforgiven created

    Can You help me to override "UserValidator" ?

  • User Avatar
    0
    behiunforgiven created

    I wrote PasswordValidator like this

    PasswordValidator = new PasswordValidator() {
                    RequiredLength = 6,
                    RequireNonLetterOrDigit = false,
                    RequireDigit = false,
                    RequireLowercase = false,
                    RequireUppercase = false
                };
    

    but I Can't create UserValidator because of its arguments

    UserValidator = new UserValidator<ApplicationUser>(manager)
                {
                    AllowOnlyAlphanumericUserNames = false,
                    RequireUniqueEmail = false
                };
    

    what is "ApplicationUser" and "manager" in Module Zero?

  • User Avatar
    0
    behiunforgiven created

    I made UserValidator Like this

    UserValidator = new UserValidator<User, long>(this)
                {
                    RequireUniqueEmail = false,
                    AllowOnlyAlphanumericUserNames = false
                };
    

    in the constructor of UserManager, but it still has Error on Emails. I want to Use One Email for All users and Authenticate them only by UserName;

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    User manager itself checks email adress uniqueness (see <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero/Authorization/Users/AbpUserManager.cs#L460">https://github.com/aspnetboilerplate/mo ... er.cs#L460</a>). So, if you user UserManager's CreateAsync method while creating users, their email adress will be unique.

    But UserManager.LoginAsync method uses email or user name to login. I think this is better and widely used. If it's really needed, you may override or create your own LoginAsync method.