コード例 #1
0
ファイル: AuthController.cs プロジェクト: nwendel/brickpile
        public async Task<ActionResult> LogIn(LogInModel model) {

            if (!ModelState.IsValid) {
                return View();
            }

            using (var session = _store.OpenSession()) {

                using (var userManager = Startup.UserManagerFactory.Invoke(session)) {

                    var user = await userManager.FindAsync(model.Email, model.Password);

                    if (user != null) {
                        var identity = await userManager.CreateIdentityAsync(
                            user, DefaultAuthenticationTypes.ApplicationCookie);
                        identity.AddClaim(new Claim(ClaimTypes.Email, user.Email));
                        GetAuthenticationManager().SignIn(identity);

                        return Redirect(GetRedirectUrl(model.ReturnUrl));
                    }

                    // user auth failed
                    ModelState.AddModelError("", "Invalid email or password");
                    return View();
                }
            }
        }
コード例 #2
0
ファイル: AuthController.cs プロジェクト: nwendel/brickpile
        public ActionResult LogIn(string returnUrl) {
            var model = new LogInModel
            {
                ReturnUrl = returnUrl
            };

            return View(model);
        }