public async Task <ApiResponseDto> Logout(string returnUrl = null) { var response = await _httpClient.PostJsonAsync <ApiResponseDto>("api/Account/Logout", null); if (response.IsSuccessStatusCode) { var logoutModel = new AccountFormModel() { ReturnUrl = returnUrl }; if (_navigationManager.IsWebAssembly()) { if (!string.IsNullOrEmpty(logoutModel.ReturnUrl)) { _navigationManager.NavigateTo(logoutModel.ReturnUrl); } } else { await SubmitServerForm("/server/logout/", logoutModel); } } return(response); }
private void ValidateFormModel(AccountFormModel model) { if (string.IsNullOrEmpty(model.UserName)) { ModelState.AddModelError("UserName", "Chưa nhập email đăng nhập"); } else if (string.IsNullOrEmpty(model.PassWord)) { ModelState.AddModelError("PassWord", "Chưa nhập mật khẩu"); } }
/// <summary> /// load controls in the form /// </summary> /// <param name="pref"></param> /// <returns></returns> public JsonResult LoadControls(int windowNo, int C_AcctSchema_ID) { if (Session["Ctx"] != null) { var ctx = Session["ctx"] as Ctx; AccountFormModel obj = new AccountFormModel(); var value = obj.AccountSchemaLoad(ctx, windowNo, C_AcctSchema_ID); return(Json(new { result = value }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = "ok" }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Save Account Schema Records /// </summary> /// <param name="windowNo"></param> /// <param name="C_AcctSchema_ID"></param> /// <returns></returns> public JsonResult Save(string AD_Client_ID, string AD_Org_ID, string C_AcctSchema_ID, string AD_Account_ID, string C_SubAcct_ID, string M_Product_ID, string C_BPartner_ID, string AD_OrgTrx_ID, string C_LocFrom_ID, string C_LocTo_ID, string C_SRegion_ID, string C_Project_ID, string C_Campaign_ID, string C_Activity_ID, string User1_ID, string User2_ID, string Alias) { if (Session["Ctx"] != null) { var ctx = Session["ctx"] as Ctx; AccountFormModel obj = new AccountFormModel(); var value = obj.SaveAccount(ctx, Convert.ToInt32(AD_Client_ID), Convert.ToInt32(AD_Org_ID), Convert.ToInt32(C_AcctSchema_ID), Convert.ToInt32(AD_Account_ID), Convert.ToInt32(C_SubAcct_ID), Convert.ToInt32(M_Product_ID), Convert.ToInt32(C_BPartner_ID), Convert.ToInt32(AD_OrgTrx_ID), Convert.ToInt32(C_LocFrom_ID), Convert.ToInt32(C_LocTo_ID), Convert.ToInt32(C_SRegion_ID), Convert.ToInt32(C_Project_ID), Convert.ToInt32(C_Campaign_ID), Convert.ToInt32(C_Activity_ID), Convert.ToInt32(User1_ID), Convert.ToInt32(User2_ID), Alias); return(Json(new { result = value }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = "ok" }, JsonRequestBehavior.AllowGet)); }
public ActionResult SignIn(AccountFormModel model, string returnUrl) { ValidateFormModel(model); //var errors = ModelState.Values.SelectMany(value => value.Errors).ToList(); if (ModelState.IsValid) { var isLoginSuccessful = LoginAction(() => _accountService.AuthenticateUser(model.UserName, model.PassWord), new string[] { "FullName", "UserName" }); if (isLoginSuccessful) { return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("Login", "Đăng nhập thất bại!"); } } return(View(model)); }
public async Task <IActionResult> Create(AccountFormModel accountModel) { if (!ModelState.IsValid) { return(View(accountModel)); } var userId = this.userManager.GetUserId(User); await this.accounts.CreateAsync( accountModel.Name, accountModel.Address, accountModel.Description, userId); TempData.AddSuccessMessage($"Account {accountModel.Name} created successfully!"); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, AccountFormModel model) { if (!await this.ValidateUserIsAssignedAccountManager(id)) { return(Unauthorized()); } if (!ModelState.IsValid) { return(View(model)); } var serviceModel = await this.accounts.GetByIdAsync(id); if (serviceModel == null) { return(BadRequest()); } await this.accounts.EditAsync(id, model.Name, model.Description, model.Address); TempData.AddSuccessMessage($"Account {model.Name} edited successfully!"); return(RedirectToAction(nameof(Details), routeValues: new { id = id })); }
private async Task SubmitServerForm(string path, AccountFormModel model) { model.__RequestVerificationToken = await _jsRuntime.InvokeAsync <string>("interop.getElementByName", "__RequestVerificationToken"); await _jsRuntime.InvokeAsync <string>("interop.submitForm", path, model); }
public async Task <IActionResult> OnPostAsync(AccountFormModel model) { await _accountManager.ForgetTwoFactorClient(User); return(LocalRedirect(Url.Content($"~{Settings.ProfilePath}"))); }
public async Task <IActionResult> OnPostAsync(AccountFormModel model) { await _accountManager.Logout(User); return(LocalRedirect(Url.Content($"~{model.ReturnUrl}"))); }