Beispiel #1
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl ??= Url.Content("~/");

            if (ModelState.IsValid)
            {
                //Need to check account.
                //if (result is invalid)
                switch (_signInService.CheckAccount(Input.Email, Input.Password))
                {
                case AccountStatus.Banned:
                    ModelState.AddModelError(string.Empty, "Your account has been banned.");
                    return(Page());

                case AccountStatus.Disabled:
                    ModelState.AddModelError(string.Empty, "Your account has been disabled.");
                    return(Page());

                case AccountStatus.Unauthenticated:
                    ModelState.AddModelError(string.Empty, "Invalid credentials.");
                    return(Page());

                case AccountStatus.LockedOut:
                    ModelState.AddModelError(string.Empty, "Account locked.");
                    return(Page());

                case AccountStatus.PendingVerification:
                    ModelState.AddModelError(string.Empty, "Your account is pending verification.");
                    return(Page());

                case AccountStatus.Ok:
                    await _signInService.SignInAsync(Input.Email, Input.RememberMe, HttpContext);

                    return(LocalRedirect(returnUrl));
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError(string.Empty, "An unexpected error occured.");
            return(Page());
        }