//[ValidateAntiForgeryToken]
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            User applicationUser = new User();
            var  loginResult     = BoardSquaresRepository.AttemptLogin(model.Email, model.Password);

            switch (loginResult)
            {
            case -1:
                ViewBag.ErrorMessage = "No Accounts found with specified Email";
                return(View(model));

            case 0:
                ViewBag.ErrorMessage = "Incorrect Password";
                return(View(model));

            default:
                applicationUser = BoardSquaresRepository.GetUserByID(loginResult);
                break;
            }

            var claims = new[] {
                new Claim(ClaimTypes.Email, applicationUser.Email),
                new Claim(ClaimTypes.NameIdentifier, applicationUser.Email),
                new Claim(ClaimTypes.Name, applicationUser.UserName)
                // can add more claims
            };

            var identity   = new ClaimsIdentity(claims, "ApplicationCookie");
            var roleClaims = new Claim(ClaimTypes.Role, applicationUser.AdminRole ? "Admin" : "User");

            identity.AddClaim(roleClaims);
            var context     = Request.GetOwinContext();
            var authManager = context.Authentication;

            authManager.SignIn(new AuthenticationProperties {
                IsPersistent = true,
            }, identity);
            return(RedirectToAction("Index", "Home"));
        }