Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public UserDTO Registration([FromBody] UserForAuthDTO value)
 {
     return(BusinesLogic.AuthService.Register(value));
 }
Exemplo n.º 4
0
 public UserDTO Login([FromBody] UserForAuthDTO value)
 {
     return(BusinesLogic.AuthService.Login(value));
 }