Пример #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (AppUsrMng != null)
                {
                    AppUsrMng.Dispose();
                    AppUsrMng = null;
                }

                if (AppSignMng != null)
                {
                    AppSignMng.Dispose();
                    AppSignMng = null;
                }
            }

            base.Dispose(disposing);
        }
Пример #2
0
        public async Task <ActionResult> Register(PersonaVM model)
        {
            if (ModelState.IsValid)
            {
                var user = new Persona {
                    UserName = model.Email, Email = model.Email, Apellidos = model.Apellido, Nombre = model.Nombre, Direccion = model.Direccion, PhoneNumber = model.PhoneNumber
                };
                var result = await AppUsrMng.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await AppSignMng.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #3
0
        public async Task <ActionResult> ResetPassword(object model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await AppUsrMng.FindByNameAsync("email");

            if (user == null)
            {
                // Don't reveal that the user does not exist
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            var result = await AppUsrMng.ResetPasswordAsync(user.Id, "code", "password");

            if (result.Succeeded)
            {
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            AddErrors(result);
            return(View());
        }
Пример #4
0
        public async Task <ActionResult> ForgotPassword(object model)
        {
            if (ModelState.IsValid)
            {
                var user = await AppUsrMng.FindByNameAsync("nombre");

                if (user == null)
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return(View("ForgotPasswordConfirmation"));
                }

                // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                string code = await AppUsrMng.GeneratePasswordResetTokenAsync(user.Id);

                return(RedirectToAction("ResetPassword", "Account", new { code = code }));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }