Identity 2.0 with custom tables

前端 未结 3 456
予麋鹿
予麋鹿 2021-01-30 08:59

I\'m new to ASP.NET identity and am still trying to get my head around how it all works. Unfortunately I\'ve found many of the tutorials I\'ve tried are for Identity 1.0, wherea

3条回答
  •  感情败类
    2021-01-30 09:44

    I think this has been updated recently to this in ApplicationUser:

    public async Task GenerateUserIdentityAsync(UserManager manager, string authenticationType)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
        // Add custom user claims here
        return userIdentity;
    }
    

    It is called like this from AccountController -> GetExternalLogin

    ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(UserManager,
        OAuthDefaults.AuthenticationType);
    ClaimsIdentity cookieIdentity = await user.GenerateUserIdentityAsync(UserManager,
        CookieAuthenticationDefaults.AuthenticationType);
    

提交回复
热议问题