Пример #1
0
        public IActionResult OnPost()
        {
            AuthUser = _usersRepository.GetAuthUser(Anon.Email, Cryptography.GetHashString(Anon.Password));

            if (AuthUser is null)
            {
                Message = "Не верные данные!";
                return(Page());
            }
            else
            {
                HttpContext.Session.Set <RegisterModel>("AuthUser", AuthUser);
                HttpContext.Session.Set("AuthReady", "true");
                HttpContext.Response.Cookies.Append("Email", AuthUser.Email);

                if (save)
                {
                    Random random = new Random();

                    AuthUser.CookieId = random.Next(1, 10000000).ToString();
                    _usersRepository.EditUserCookie(AuthUser);
                    HttpContext.Response.Cookies.Append("CookieId", AuthUser.CookieId);
                }

                return(Redirect("/Profile/" + AuthUser.Id.ToString()));
            }
        }