public async Task <IActionResult> FinalizeSignUp([AuditIgnore][FromBody] VerifiedSignUpViewModel newUserInfo) { RServiceResult <bool> result = await _appUserService.FinalizeSignUp(newUserInfo.Email, newUserInfo.Secret, newUserInfo.Password, newUserInfo.FirstName, newUserInfo.SureName); if (!result.Result) { return(BadRequest(result.ExceptionString)); } return(Ok(true)); }
public async Task <IActionResult> OnPostPhase3Async() { LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Name"]); LastError = ""; SignupPhase1 = false; SignupVerifyEmailPhase = false; SignupFinalPhase = true; if (FinalViewModel.Password != FinalViewModel.PasswordConfirmation) { LastError = "گذرواژه و تکرار آن یکی نیستند."; return(Page()); } VerifiedSignUpViewModel postViewModel = new VerifiedSignUpViewModel() { Email = FinalViewModel.Email, Secret = FinalViewModel.Secret, FirstName = FinalViewModel.FirstName, SureName = FinalViewModel.SureName, Password = FinalViewModel.Password }; var response = await _httpClient.PostAsync($"{APIRoot.Url}/api/users/finalizesignup", new StringContent(JsonConvert.SerializeObject(postViewModel), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } LoginViewModel loginViewModel = new LoginViewModel() { ClientAppName = "وبگاه گنجور", Language = "fa-IR", Username = postViewModel.Email, Password = postViewModel.Password }; var stringContent = new StringContent(JsonConvert.SerializeObject(loginViewModel), Encoding.UTF8, "application/json"); var loginUrl = $"{APIRoot.Url}/api/users/login"; response = await _httpClient.PostAsync(loginUrl, stringContent); if (!response.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } LoggedOnUserModelEx loggedOnUser = JsonConvert.DeserializeObject <LoggedOnUserModelEx>(await response.Content.ReadAsStringAsync()); var cookieOption = new CookieOptions() { Expires = DateTime.Now.AddDays(365), }; Response.Cookies.Append("UserId", loggedOnUser.User.Id.ToString(), cookieOption); Response.Cookies.Append("SessionId", loggedOnUser.SessionId.ToString(), cookieOption); Response.Cookies.Append("Token", loggedOnUser.Token, cookieOption); Response.Cookies.Append("Username", loggedOnUser.User.Username, cookieOption); Response.Cookies.Append("Name", $"{loggedOnUser.User.FirstName} {loggedOnUser.User.SureName}", cookieOption); Response.Cookies.Append("NickName", $"{loggedOnUser.User.NickName}", cookieOption); Response.Cookies.Append("KeepHistory", $"{loggedOnUser.KeepHistory}", cookieOption); bool canEditContent = false; var ganjoorEntity = loggedOnUser.SecurableItem.Where(s => s.ShortName == RMuseumSecurableItem.GanjoorEntityShortName).SingleOrDefault(); if (ganjoorEntity != null) { var op = ganjoorEntity.Operations.Where(o => o.ShortName == SecurableItem.ModifyOperationShortName).SingleOrDefault(); if (op != null) { canEditContent = op.Status; } } Response.Cookies.Append("CanEdit", canEditContent.ToString(), cookieOption); return(Redirect($"{_configuration["SiteUrl"]}/User")); }