Пример #1
0
        public IActionResult UserControl(UserLogin userForm)
        {
            MySqlDatabase msDB   = new MySqlDatabase();
            UserLogin     uLogin = msDB.userControl(userForm.Email, userForm.Password);

            msDB.Dispose();
            if (uLogin != null)
            {
                var userClaims = new List <Claim> {
                };
                if (uLogin.AccountInfoEx)
                {
                    userClaims = new List <Claim>
                    {
                        new Claim(ClaimTypes.NameIdentifier, uLogin.Id.ToString()),
                        new Claim(ClaimTypes.Name, uLogin.DisplayName),
                        new Claim(ClaimTypes.Email, uLogin.Email)
                    };
                }
                else
                {
                    userClaims = new List <Claim>
                    {
                        new Claim(ClaimTypes.NameIdentifier, uLogin.Id.ToString()),
                        new Claim(ClaimTypes.Email, uLogin.Email)
                    };
                }

                var grandmaIdentity = new ClaimsIdentity(userClaims, "User Identity");

                var userPrincipal = new ClaimsPrincipal(new[] { grandmaIdentity });
                HttpContext.SignInAsync(userPrincipal);
                if (uLogin.AccountInfoEx)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    return(RedirectToAction("Index", "AccountInfo"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Login"));
            }
        }
Пример #2
0
 public void Dispose()
 {
     MySqlDatabase?.Dispose();
     MySqlServer?.Dispose();
     ConexaoString = string.Empty;
 }