public IActionResult SignUp(RegisterViewModel model) { bool checkUser = _authRepository.CheckEmail(model.Email); bool number = _authRepository.CheckPhone(model.Phone); if (checkUser) { ModelState.AddModelError("Email", "Bu E-mail artiq movcuddur"); } if (number) { ModelState.AddModelError("Phone", "Bu Nömrə artıq mövcuddur"); } if (ModelState.IsValid) { var user = _mapper.Map<RegisterViewModel, Account>(model); user.Fullname = model.Name + " " + model.Surname; user.Token = Guid.NewGuid().ToString(); user.Status = true; user.IsEmailVerified = false; //email verification code user.EmailActivationCode = Guid.NewGuid().ToString(); _authRepository.Register(user); AccountSocialLink accountSocialLink = new AccountSocialLink { AccountId = user.Id, Status = true, AddedBy = "System", AddedDate = DateTime.Now }; _authRepository.AddedSocial(accountSocialLink); //creating account's privacy Database AccountPrivacy accountPrivacy = new AccountPrivacy { AccountId = user.Id, Status = true, AddedDate = DateTime.Now, AddedBy = "System", Phone = true, Email = true, LastLogin = true, LastSeen = true, Address = true, Birthday = true, ProfileImg = true, SocialLink = true, StatusText = true, Website = true }; _authRepository.CreatePrivacy(accountPrivacy); AccountSecurity accountSecurity = new AccountSecurity { AccountId=user.Id, TwoFactoryAuth = false, LoginAlerts = false }; _authRepository.CreateSecurity(accountSecurity); //send verification link email string userFullname = user.Name + " " + user.Surname; string link = HttpContext.Request.Scheme + "://" + Request.Host + "/account/verifyemail/" + user.EmailActivationCode; _emailService.VerificationEmail(user.Email, link, user.EmailActivationCode, userFullname); Response.Cookies.Append("token", user.Token, new Microsoft.AspNetCore.Http.CookieOptions { HttpOnly = true, Expires = DateTime.Now.AddYears(1) }); return RedirectToAction("chat1", "pages"); } return View(model); }