public IActionResult OnPost() { if (!ModelState.IsValid) { ViewData["Message"] = "格式錯誤"; return(Page()); //return RedirectToPage("./Error"); } var accSvc = new AccountSvcClient(); UserModel user = accSvc.AuthenticateUser(LoginInfo); if (user != null) { _env.SetLoginUserInfo(user); this.SigninWithCookieAuth(user); // success return(Redirect("~/index")); } accSvc.CloseAsync(); ViewData["Message"] = "登入失敗!"; return(Page()); }
public IActionResult Login(LoginInfo login) { _logger.LogInformation($"Login {login.ToJson()}"); var accSvc = _env.CreateAccountSvcClient(); string accSvcUrl = accSvc.Endpoint.Address.Uri.ToString(); _logger.LogTrace("認證網址:{accSvcUrl}。", accSvcUrl); UserModel user = accSvc.AuthenticateUser(login); if (user != null) { _env.SetLoginUserInfo(user); this.SigninWithCookieAuth(user); return(Ok()); } accSvc.CloseAsync(); return(Unauthorized()); }