Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
        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()
                }
            });
        }
Exemplo n.º 3
0
        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);
        }