public ProtoUserProjection(IProtoUser existing) { Id = existing.Id; UserName = existing.UserName; DisplayName = existing.DisplayName; IsActivated = existing.IsActivated; PasswordHash = existing.PasswordHash; PhotoUrl = existing.PhotoUrl; CreatedUtc = existing.CreatedUtc; UpdatedUtc = existing.UpdatedUtc; }
public FurtherValidationResult CreateProtoUser(IProtoUser user) { var ir = CreateAsync((ApplicationUser)user).Result; if (ir.Succeeded) { return(FurtherValidationResult.Ok); } return(new FurtherValidationResult { Errors = { [FurtherValidationResult.GLOBAL_ERROR_FIELD_NAME] = ir.Errors.ToArray() } }); }
public static ClaimsIdentity GenerateUserIdentity(OAuthGrantResourceOwnerCredentialsContext context, IProtoUser user, IProtoUserManager userMgr) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim("userId", user.Id)); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); identity.AddClaim(new Claim("userName", user.UserName)); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); identity.AddClaim(new Claim("displayName", user.DisplayName ?? user.UserName)); identity.AddClaim(new Claim(ClaimTypes.GivenName, user.DisplayName ?? user.UserName)); foreach (var r in userMgr.GetProtoRoleNames(user.Id)) { identity.AddClaim(new Claim(ClaimTypes.Role, r)); identity.AddClaim(new Claim("role", r)); } return(identity); }