public async Task <IActionResult> Login(DTOs.UserLogin user) { try { var userOnline = await _repository.Login(user.Username, user.Password); if (userOnline == null) { return(Unauthorized()); } var utilJwt = new Util.JwtGenerator(_config); var actualToken = utilJwt.GenerateToken(userOnline.Id.ToString(), userOnline.Username); var tokenHandler = utilJwt.GetJwtHandler(); return(Ok(new { token = tokenHandler.WriteToken(actualToken) })); //var jwtToken = new JwtSecurityToken //{ // Claims = claims, // SigningCredentials = creds, //}; //jwtToken.ValidFrom = DateTime.Now; //jwtToken.ValidTo = DateTime.Now.AddMinutes(30); } catch (Exception ex) { throw ex; } }
public User(DTOs.UserLogin login) { Email = login.Email; Password = login.Password; }