public async Task <IActionResult> Registration(UserRegistrationVM registrationVM) { if (db.users.Any(u => u.login == registrationVM.login)) { ModelState.AddModelError(nameof(registrationVM.login), "This login is already in use"); } if (registrationVM.email != null && db.users.Any(u => u.email == registrationVM.email)) { ModelState.AddModelError(nameof(registrationVM.email), "This email is already in use"); } if (registrationVM.password != registrationVM.confirmPassword) { ModelState.AddModelError(nameof(registrationVM.password), "Passwords are not same"); } if (ModelState.IsValid) { UserModel user = registrationVM.GetDbModel(); db.users.Add(user); db.SaveChanges(); await Authenticate(user.login); HttpContext.Session.SetString("login", user.login); var session = HttpContext.Session.SessionInfo(); resultBuilder.AddJSFuncModel("updateUserInfo", session); resultBuilder.AddJSFuncInline("reloadHubConnection"); return(Json(resultBuilder.Build())); } else { resultBuilder.AddAspView(this, "Registration", registrationVM); return(Json(resultBuilder.Build())); } }
public IActionResult login() { terminalResultBuilder.AddAspView(this, "SignIn"); return(Json(terminalResultBuilder.Build())); }