private void InsertClaims(M1User user)
 {
     foreach (var claim in user.Claims)
     {
         Insert.IntoTable("UserClaim").InSchema("Membership").Row(new
         {
             UserId = user.UserId,
             Type   = claim.Type,
             Value  = claim.Value
         });
     }
 }
Exemple #2
0
 private void InsertClaims(M1User user)
 {
     foreach (var claim in user.Claims)
     {
         Insert.IntoTable("UserClaim").InSchema("Membership").Row(new
         {
             UserId = user.UserId,
             Type = claim.Type,
             Value = claim.Value
         });
     }
 }
 private void InsertProfile(M1User user)
 {
     if (user.Profile != null)
     {
         Insert.IntoTable("UserProfile").InSchema("Membership").Row(new
         {
             UserId               = user.UserId,
             FirstName            = new ExplicitUnicodeString(user.Profile.FirstName),
             LastName             = new ExplicitUnicodeString(user.Profile.LastName),
             Email                = user.Profile.Email,
             PhoneNumber          = user.Profile.PhoneNumber,
             SecretPhrase         = new ExplicitUnicodeString(user.Profile.SecretPhrase),
             PhoneNumberConfirmed = user.Profile.PhoneNumberConfirmed
         });
     }
 }
Exemple #4
0
 private void InsertProfile(M1User user)
 {
     if (user.Profile != null)
     {
         Insert.IntoTable("UserProfile").InSchema("Membership").Row(new
         {
             UserId = user.UserId,
             FirstName = new ExplicitUnicodeString(user.Profile.FirstName),
             LastName = new ExplicitUnicodeString(user.Profile.LastName),
             Email = user.Profile.Email,
             PhoneNumber = user.Profile.PhoneNumber,
             SecretPhrase = new ExplicitUnicodeString(user.Profile.SecretPhrase),
             PhoneNumberConfirmed = user.Profile.PhoneNumberConfirmed
         });
     }
 }
        public override void Up()
        {
            var users = new List <M1User>()
            {
                M1User.Create("smolyakoff", DevPassword, "Admin", new M1Profile()
                {
                    Email                = "*****@*****.**",
                    FirstName            = "Константин",
                    LastName             = "Смоляков",
                    PhoneNumber          = "+375293593295",
                    PhoneNumberConfirmed = true
                }),
                M1User.Create("losik", DevPassword, "Admin"),
                M1User.Create("sherbetr", DevPassword, "Admin"),
                M1User.Create("jaymz", DevPassword, "Admin"),
                M1User.Create("gostop", DevPassword, "Admin"),
                M1User.Create("bradpitt", DevPassword, "Customer", new M1Profile()
                {
                    Email     = "*****@*****.**",
                    FirstName = "Брэд",
                    LastName  = "Питт"
                }),
                M1User.Create("terminator", DevPassword, "Customer",
                              new M1Profile()
                {
                    Email     = "*****@*****.**",
                    FirstName = "Арнольд",
                    LastName  = "Шварцнеггер"
                }),
                M1User.Create("meganfox", DevPassword, "Customer", new M1Profile()
                {
                    Email     = "*****@*****.**",
                    FirstName = "Меган",
                    LastName  = "Фокс"
                }),
            };

            users.ForEach(x =>
            {
                InsertUser(x);
                InsertClaims(x);
                InsertProfile(x);
            });
        }
Exemple #6
0
 public static M1User Create(string login, string password, string role, M1Profile profile = null)
 {
     var user = new M1User
     {
         UserId = Guid.NewGuid(),
         UserName = login,
         Password = Password.Create(password),
         Claims = new List<Claim>
         {
             new Claim(ClaimTypes.Name, login),
             new Claim(ClaimTypes.Role, role)
         },
         Profile = profile
     };
     user.Claims.Add(new Claim(ClaimTypes.Sid, user.UserId.ToString()));
     var credentials = user.Claims.OrderBy(x => x.Type).Select(x => x.ToString());
     user.SecurityStamp = Hash.Compute(credentials);
     return user;
 }
Exemple #7
0
        public static M1User Create(string login, string password, string role, M1Profile profile = null)
        {
            var user = new M1User
            {
                UserId   = Guid.NewGuid(),
                UserName = login,
                Password = Password.Create(password),
                Claims   = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, login),
                    new Claim(ClaimTypes.Role, role)
                },
                Profile = profile
            };

            user.Claims.Add(new Claim(ClaimTypes.Sid, user.UserId.ToString()));
            var credentials = user.Claims.OrderBy(x => x.Type).Select(x => x.ToString());

            user.SecurityStamp = Hash.Compute(credentials);
            return(user);
        }
 private void InsertUser(M1User user)
 {
     Insert.IntoTable("User").InSchema("Membership").Row(user.ToTableRow());
 }
Exemple #9
0
 private void InsertUser(M1User user)
 {
     Insert.IntoTable("User").InSchema("Membership").Row(user.ToTableRow());
 }