public async Task <IActionResult> Login(User_Auth user_Auth) { var user = userServices.Login(user_Auth); if (user.id == 0) { return(Unauthorized()); } if (user.token == null && user.exp == null) { (string token, DateTime exp) = Helper.GenerateToken(user.id, configuration); var rs = await userServices.AddTokenForUser(user.id, token, exp); if (rs == false) { return(Unauthorized()); } return(Ok(new { token = token })); } return(Ok(new { token = user.token })); }