Ejemplo n.º 1
0
        public ActionResult ChangePassword(UsuarioModels model)
        {
            if (ModelState.IsValid)
            {

                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.Senha, model.Senha);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Index(UsuarioModels usuario)
        {
            var usuLogin = ConfigurationManager.AppSettings["Login"].ToString();
            var usuSenha = ConfigurationManager.AppSettings["Senha"].ToString();
            if (Request.Form["login"].Equals(usuLogin) && Request.Form["senha"].Equals(usuSenha))
            {
                FormsAuthentication.SetAuthCookie("Administrador", true);
                return RedirectToAction("Index","Home");
            }
            else
            {
                ModelState.AddModelError("", "Usuário ou senha incorretos.");
            }

            return View("LogOn");
        }
Ejemplo n.º 3
0
 public ActionResult LogOn(UsuarioModels model)
 {
     return View();
 }
Ejemplo n.º 4
0
        public ActionResult Register(UsuarioModels model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.Login, model.Senha, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.Login, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Girls");
                }
                else
                {
                    return RedirectToAction("Index", "Girls");
                    //ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

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