public string SignIn(User user) { int userId = userSignIn.SignIn(user); string jwt = null; if (userId > 0) { jwt = tokenHandler.CreateToken(userId, user.Username); } if (!string.IsNullOrEmpty(jwt)) { return(jwt); } throw new Exception(); }
public async Task <string> GetAuthenticationToken(string email, string password) { var username = new UserName(email); if (string.IsNullOrWhiteSpace(password)) { throw new DomainException("Contraseña no puede estar vacía"); } await userSignIn.SignIn(username.ToString(), password); var user = await userRepository.GetUser(username); string token = tokenGenerator.GenerateToken(user); return(token); }