public async Task <IActionResult> Authorize([FromBody] AuthorizeTokenViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } return(Json(new { access_token = "12345" })); //Unauthorized(); }
public IActionResult Authorize([FromBody] LoginUserViewModel model) { AuthorizeTokenViewModel strToken = oLoginBiz.Authorize(model, _httpcontext); if (!string.IsNullOrEmpty(strToken.Token)) { strToken.Status = "Login success"; return(StatusCode(StatusCodes.Status201Created, strToken)); } else { if (oLoginBiz.AuthorizeExist(model)) { strToken.Status = "Wrong password"; return(StatusCode(StatusCodes.Status400BadRequest, strToken.Status)); } else { strToken.Status = "Username not found"; return(StatusCode(StatusCodes.Status404NotFound, strToken.Status)); } } }