示例#1
0
        private async Task CreateUsers(StudioContext context)
        {
            var users = new[]
            {
                new User
                {
                    Active     = true,
                    BirthDate  = DateTime.Now - TimeSpan.FromDays(6570),
                    Cpf        = _settings.DefaultUserCpf,
                    Email      = _settings.DefaultUserEmail,
                    Name       = "Giovanni Sunner",
                    Password   = _hash.Of(_settings.DefaultUserPassword),
                    Phone      = "11940028922",
                    SocialName = null
                },
                new User
                {
                    Active     = true,
                    BirthDate  = DateTime.Now - TimeSpan.FromDays(14600),
                    Cpf        = _settings.SuperUserCpf,
                    Email      = _settings.SuperUserEmail,
                    Name       = "Silva Gunther",
                    Password   = _hash.Of(_settings.SuperUserPassword),
                    Phone      = "11910101010",
                    SocialName = "Gilva Sunther"
                }
            };

            foreach (var user in users)
            {
                await context.Users.AddAsync(user);
            }

            await context.SaveChangesAsync();
        }
示例#2
0
 public Employee ToModel(Occupation occupation, IPasswordHash passwordHash)
 {
     return(new Employee
     {
         AccessLevel = AccessLevel,
         Gender = Gender,
         Occupation = occupation,
         OccupationId = occupation.Id,
         ParticipatingPhotoShoots = null,
         Rg = Rg,
         User = new User
         {
             Active = true,
             BirthDate = BirthDate,
             Cpf = Misc.StripCpf(Cpf),
             Email = Email,
             Name = Name,
             Password = Password == null
                 ? null
                 : passwordHash.Of(Password),
             Phone = Phone,
             SocialName = SocialName
         },
         UserId = Cpf
     });
 }
示例#3
0
        private async Task <User?> AuthenticateUser(InputLogin login)
        {
            var user = await FindUserWithLogin(login.Login);

            var hash = _passwordHash.Of(login.Password);

            if (user != null)
            {
                if (user.Password != hash)
                {
                    user = null;
                }
            }

            return(user);
        }
示例#4
0
 public void HashPassword(IPasswordHash passwordHash)
 {
     Password = passwordHash.Of(Password);
 }