Пример #1
0
        public async Task <IActionResult> LoginBD(UserLoginAndRegister currentUser)
        {
            var result = await _signInManager.PasswordSignInAsync(currentUser.UserName, currentUser.Password, true, false);

            if (!result.Succeeded)
            {
                return(RedirectToAction("Index", "LandingPages"));
            }

            return(RedirectToAction("Index", "AppPages"));
        }
Пример #2
0
        public async Task <IActionResult> RegistroBD(UserLoginAndRegister newUser)
        {
            CustomUserFields _newUser = new CustomUserFields
            {
                UserName = newUser.UserName,
                Email    = newUser.Email,
                ImageUrl = "/img/static/avatar.png"
            };

            IdentityResult result = await _userManager.CreateAsync(_newUser, newUser.Password);

            if (!result.Succeeded)
            {
                return(RedirectToAction("Registro", "LandingPages"));
            }

            await _userManager.AddToRoleAsync(_newUser, "Usuario");

            return(RedirectToAction("Index", "LandingPages"));
        }