Exemplo n.º 1
0
        public ActionResult Login( string username, string password )
        {
            Exception err = null;
            Common.User user = null;
            try
            {
                user = Authentication.AuthenticateUser( username, password );
            }
            catch( Exception e )
            {
                err = e;
            }

            var model = new LoginModel
            {
                Username = username,
                Password = password
            };

            if( user == null )
            {
                ViewBag.Error = "Username or password was invalid";

                return View( model );
            }
            else if( err != null )
            {
                ViewBag.Error = err.Message;
                return View( model );
            }
            else
            {
                return RedirectToAction( "Index", "Maintenance" );
            }
        }
Exemplo n.º 2
0
        public ActionResult Login( LoginModel model, string returnUrl )
        {
            if( ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe) )
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
Exemplo n.º 3
0
 public ActionResult Login()
 {
     var model = new LoginModel();
     return View( model );
 }