public UserDTO Login(UserForAuthDTO user) { User userGet = context.AuthRepos.Get(user.Name); if (user == null) { throw new UserNoExistException(); } if (!VerifyPasswordHash(user.Password, userGet.PasswordHash, userGet.PasswordSalt)) { throw new WrongPasswordException(); } return(mapper.Map <User, UserDTO>(userGet)); }
public UserDTO Register(UserForAuthDTO user) { user.Name = user.Name.ToLower(); if (context.AuthRepos.UserExists(user.Name)) { throw new UserAlreadyExistException(); } byte[] passwordHash, passwordSalt; CreatePasswordHash(user.Password, out passwordHash, out passwordSalt); UserDTO registr = new UserDTO(user.Name, passwordHash, passwordSalt, 0); context.AuthRepos.Create(mapper.Map <UserDTO, User>(registr)); return(registr); }
public UserDTO Registration([FromBody] UserForAuthDTO value) { return(BusinesLogic.AuthService.Register(value)); }
public UserDTO Login([FromBody] UserForAuthDTO value) { return(BusinesLogic.AuthService.Login(value)); }