Exemplo n.º 1
0
        public async Task <string> SignOutAsync(string email, string firstName, string lastName, int age,
                                                string password)
        {
            var user = await _userRepository.FindAsync(email);

            if (user != null)
            {
                throw new Exception("User with same login already exist exist");
            }

            var newUser = new User
            {
                Email        = email,
                FirstName    = firstName,
                LastName     = lastName,
                Age          = age,
                PasswordHash = Crypter.Sha512.Crypt(password)
            };

            await _userRepository.CreateAsync(newUser);

            var token = JwtTokenUtil.Generate(newUser.Email);

            return(token);
        }
Exemplo n.º 2
0
        public async Task <string> SignInAsync(string login, string password)
        {
            var user = await _userRepository.FindAsync(login);

            if (user == null)
            {
                throw new Exception("User does not exist");
            }

            var token = JwtTokenUtil.Generate(user.Email);

            return(token);
        }