public async Task <IActionResult> Register(SignUpViewModel model) { if (ModelState.IsValid) { BaseModel result = await _SignUpService.SignUpAsync(model); if (result.Status) { //var webRoot = _env.WebRootPath; //get wwwroot Folder //Get TemplateFile located at wwwroot/Templates/EmailTemplate/Confirm_Your_Email.html var pathToFile = _env.WebRootPath + Path.DirectorySeparatorChar.ToString() + "Templates" + Path.DirectorySeparatorChar.ToString() + "EmailTemplates" + Path.DirectorySeparatorChar.ToString() + "Confirm_Your_Email.html"; string HtmlBody = string.Empty; using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile)) { HtmlBody = SourceReader.ReadToEnd(); } var callbackUrl = Url.Action("EmailVerification", "Shx", null, protocol: HttpContext.Request.Scheme) + "/"; await _emailVerificationService.SendEmailVerification(result.Id, HtmlBody, callbackUrl, model.FirstName + ' ' + model.LastName); } return(Json(result)); } return(Json(new BaseModel { Status = false, Messsage = UMessagesInfo.Error })); }
public async Task <ActionResult> SignUp([FromBody] RegisterViewModel signUpViewModel) { IEntity user = await _signUpService.SignUpAsync(signUpViewModel); if (user == null) { return(Conflict()); } return(Ok()); }
public async Task <ActionResult> SingUpUserForCourseAsync([FromBody] SignUpRequestDto signUpRequest) { if (!ModelState.IsValid) { return(BadRequest()); } var(courseId, user) = signUpRequest; await _asyncSignUpService.SignUpAsync(courseId, user); return(Accepted()); }
public async Task <IActionResult> SignUp(SignUpUser user) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(user.ID) && !string.IsNullOrEmpty(user.Name) && !string.IsNullOrEmpty(user.Password) && !string.IsNullOrEmpty(user.CheckPassword)) { if (user.Password != user.CheckPassword) { ViewBag.ErrorInfo = "Created and confirmed passwords are not the same"; return(View(user)); } else if (!await _signUpService.CheckId(user.ID)) { if (await _signUpService.SignUpAsync(user)) { await HttpContext.SignOutAsync(); var claimIdentity = new ClaimsIdentity("Cookie"); claimIdentity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.ID)); claimIdentity.AddClaim(new Claim(ClaimTypes.Name, user.Name)); claimIdentity.AddClaim(new Claim("Avatar", "Default.png")); claimIdentity.AddClaim(new Claim(ClaimTypes.Role, "Commom")); var claimsPrincipal = new ClaimsPrincipal(claimIdentity); await HttpContext.SignInAsync(claimsPrincipal); return(RedirectToAction("Index", "Home")); } else { ViewBag.ErrorInfo = "注册过程存在异常,请进行调试"; } } else { ViewBag.ErrorInfo = "UserId is exist"; } } else { ViewBag.ErrorInfo = "Information is incomplete"; } } return(View(user)); }
public async Task <ActionResult> SingUpUserForCourse([FromBody] SignUpRequestDto signUpRequest) { //Can be moved to filter. Removes duplication. if (!ModelState.IsValid) { return(BadRequest()); } var(courseId, user) = signUpRequest; var result = await _syncSignUpService.SignUpAsync(courseId, user); if (result.Success) { return(Ok()); } //then only way our logic can return fail - if there is no empty places return(new StatusCodeResult(StatusCodes.Status410Gone)); }
public async Task <ActionResult> SignUp([FromBody] SignUpViewModel signUpModel) { var user = await _signUpService.SignUpAsync(signUpModel.MapTo <User>()); if (user == null) { return(Conflict()); } var payload = new CreateUserPayload { DomainId = user.Id, Email = user.Email, Role = signUpModel.Role, Password = signUpModel.Password }; await _identityService.CreateUserAsync(payload); return(Ok()); }