Example #1
0
        public async Task <ActionResult> OnPostAsync([FromServices] AuthenticationReader authenticationReader)
        {
            if (ModelState.IsValid)
            {
                InfoForLoginPostHandler userInfo = await authenticationReader.GetInfoForLoginPostHandler(Form.Email);

                if (userInfo is null || PasswordHashHelper.CheckPasswordHash(Form.Password, userInfo.HashedPassword) == false)
                {
                    ModelState.AddModelError("", "The email or password is incorrect.");
                }
                else
                {
                    var authenticationTicketInfo = new SignInHelper.AuthenticationTicketInfo
                    {
                        UserId    = userInfo.UserId,
                        FirstName = userInfo.FirstName,
                        AuthTicketInfoLastChangeUtcTime = userInfo.AuthTicketInfoLastChangeUtcTime
                    };
                    await SignInHelper.SignInAsync(authenticationTicketInfo, Form.RememberMe, HttpContext);
                }
            }