Ejemplo n.º 1
0
        public UserDTO Login(string login, string password)
        {
            string hash = Model_Users.GetHash(SHA256.Create(), password);

            if (model_Users.Users.Any(el => el.Login == login && el.PasswordHash == hash))
            {
                UserDTO userDTO = mapperTo.Map <UserDTO>(model_Users.Users.FirstOrDefault(el => el.Login == login && el.PasswordHash == hash));
                return(userDTO);
            }
            return(null);
        }
Ejemplo n.º 2
0
 public bool Register(string login, string email, string password)
 {
     if (!model_Users.Users.Any(el => el.Login == login))
     {
         User user = new User()
         {
             Login = login, Email = email, PasswordHash = Model_Users.GetHash(SHA256.Create(), password)
         };
         model_Users.Users.Add(user);
         model_Users.SaveChanges();
         return(true);
     }
     return(false);
 }