public async Task <User> Authenticate(string username, string password) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(null); } var user = await _context.GetuserByUsername(username); if (user == null) { return(null); } if (password != user.Password) { return(null); } user.Token = GenerarToken(user); user.Password = null; return(user); }