public async Task <IActionResult> Login(LoginInputModel model) { if (ModelState.IsValid) { // find the user from our local user store var localUser = await _userService.FindByLoginCrentialsAsync(model.Username, model.Password); if (localUser != null) { AuthenticationProperties props = null; // only set explicit expiration here if persistent. // otherwise we reply upon expiration configured in cookie middleware. if (AccountOptions.AllowRememberLogin && model.RememberLogin) { props = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(AccountOptions.RememberMeLoginDuration) }; } ; // issue authentication cookie with subject ID and username // var user = _users.FindByUsername(model.Username); // // TODO: Move this to a LocalPasswordValidator // var optionalClaims = new List<Claim> // { // new Claim(ClaimTypes.GivenName, "Foo"), // new Claim(ClaimTypes.Surname, "Bar"), // new Claim(ClaimTypes.Name, "Foo Bar") // //new Claim(ClaimTypes.StateOrProvince, identity.State) // //new Claim(ClaimTypes.Country, "ca"), // }; // var grantValidationResult = new GrantValidationResult( // // subject: "AAA", // authenticationMethod: "custom", // claims: optionalClaims); // END // TODO: localUser.fullname? Or Username? //await HttpContext.Authentication.SignInAsync(localUser.Id.ToString(), localUser.FullName, props, optionalClaims.ToArray()); await HttpContext.Authentication.SignInAsync(localUser.Id.ToString(), localUser.FullName, props); // make sure the returnUrl is still valid, and if yes - redirect back to authorize endpoint if (_interaction.IsValidReturnUrl(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } return(Redirect("~/")); } ModelState.AddModelError("", AccountOptions.InvalidCredentialsErrorMessage); } // something went wrong, show form with error var vm = await _account.BuildLoginViewModelAsync(model); return(View(vm)); }