Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<ActionResult> Login(LoginModel details)
- {
- UserModel user = await userManager.FindUserByEmailAsync(details.Email);
- bool findingUser = await userManager.CheckUserPasswordAsync(user, details.Password);
- if (!findingUser)
- {
- ModelState.AddModelError("", "Не верно указано имя или пароль");
- }
- else
- {
- ClaimsIdentity identityClaims = await userManager.CreateUserIdentityAsync(user);
- if (identityClaims == null)
- {
- return View(details);
- }
- signInManager.UserSignOut(DefaultAuthenticationTypes.ApplicationCookie);
- signInManager.UserSignIn(identityClaims);
- return Redirect(GetRedirectUrl(details.ReturnUrl));
- }
- return View(details);
- }
- public async Task<ClaimsIdentity> CreateUserIdentityAsync(UserModel user)
- {
- ClaimsIdentity identResult = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
- return identResult;
- }
- public class UserModel : IdentityUser
- {
- public UserModel()
- {
- }
- public int Ages { get; set; }
- public string Street { get; set; }
- public int HomeNumber { get; set; }
- public int? ApartmentNumber { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement