Esempio n. 1
0
        public async Task <IActionResult> OnGetAsync(string Token)
        {
            if (!string.IsNullOrWhiteSpace(Token))
            {
                return(StatusCode(400));
            }

            string DecryptedToken = Token.AesDecrypt(AuthConst.SecretKey);
            string UserId         = DecryptedToken.Split(", ")[0];
            string Password       = DecryptedToken.Split(", ")[1];
            string Ip             = DecryptedToken.Split(", ")[2];
            string Date           = DecryptedToken.Split(", ")[3];
            bool   RemmeberMe     = bool.Parse(DecryptedToken.Split(", ")[4]);

            var Result = await _UserApplication.LoginByEmailLinkStep2Async(UserId, Password, Ip, HttpContext.Connection.RemoteIpAddress.ToString(), DateTime.Parse(Date));

            if (Result.IsSucceeded)
            {
                string GeneratedToken = await _JWTBuilder.CreateTokenAync(Result.Message);

                Response.CreateAuthCookie(GeneratedToken, RemmeberMe);

                ViewData["Message"] = _Localizer["LoginEmailSuccess"];
                ViewData["MsgType"] = "success";
                return(Page());
            }
            else
            {
                ViewData["Message"] = _Localizer[Result.Message];
                ViewData["MsgType"] = "danger";
                return(Page());
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(_MsgBox.ModelStateMsg(ModelState.GetErrors()));
            }

            var Result = await _UserApplication.LoginByPhoneNumberStep2Async(Input.PhoneNumber, Input.Code);

            if (Result.IsSucceeded)
            {
                string GeneratedToken = await _JwtBuilder.CreateTokenAync(Result.Message);

                Response.CreateAuthCookie(GeneratedToken, Input.RemmeberMe);

                return(new JsResult("GotoReturnUrl()"));
            }
            else
            {
                return(_MsgBox.FaildMsg(_Localizer[Result.Message]));
            }
        }