public ActionResult Login(Piranha.Models.LoginModel m)
        {
            // Authenticate the user
            if (ModelState.IsValid)
            {
                SysUser user = SysUser.Authenticate(m.Login, m.Password);
                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(user.Id.ToString(), m.RememberMe);
                    HttpContext.Session[PiranhaApp.USER] = user;

                    // Redirect after logon
                    if (string.IsNullOrEmpty(m.ReturnUrl))
                    {
                        return(Redirect("~/"));
                    }
                    else
                    {
                        return(Redirect(m.ReturnUrl));
                    }
                }
                else
                {
                    ViewBag.Message    = @Piranha.Resources.Account.MessageLoginFailed;
                    ViewBag.MessageCss = "error";
                }
            }
            else
            {
                ViewBag.Message    = @Piranha.Resources.Account.MessageLoginEmptyFields;
                ViewBag.MessageCss = "";
            }
            return(View());
        }
Ejemplo n.º 2
0
		public ActionResult Login(LoginModel m) {
			// Authenticate the user
			if (ModelState.IsValid) {
				SysUser user = SysUser.Authenticate(m.Login, m.Password) ;
				if (user != null) {
					FormsAuthentication.SetAuthCookie(user.Id.ToString(), m.RememberMe) ;
					HttpContext.Session[PiranhaApp.USER] = user ;

					// Redirect after logon
					/*
					var startpage =  WebPages.Manager.Menu[0].Items[0] ;

					return RedirectToAction(startpage.Action, startpage.Controller) ;
					 */
					return RedirectToAction("index", "managerstart") ;
				} else {
					ViewBag.Message = @Piranha.Resources.Account.MessageLoginFailed ;
					ViewBag.MessageCss = "error" ;
				}
			} else {
				ViewBag.Message = @Piranha.Resources.Account.MessageLoginEmptyFields ;
				ViewBag.MessageCss = "" ;
			}
			return Index() ;
		}
Ejemplo n.º 3
0
 public ActionResult Login(LoginModel m)
 {
     // Authenticate the user
     if (ModelState.IsValid) {
         SysUser user = SysUser.Authenticate(m.Login, m.Password) ;
         if (user != null) {
             FormsAuthentication.SetAuthCookie(user.Id.ToString(), m.RememberMe) ;
             HttpContext.Session[PiranhaApp.USER] = user ;
         } else {
             ViewBag.Message = "Inloggningen misslyckades" ;
         }
     } else {
         ViewBag.Message = "Du måste fylla i alla fält" ;
     }
     // Redirect after logon
     return RedirectToAction("Index", "Page") ;
 }
Ejemplo n.º 4
0
		public ActionResult RunUpdate(LoginModel m) {
			// Authenticate the user
			if (ModelState.IsValid) {
				SysUser user = SysUser.Authenticate(m.Login, m.Password) ;
				if (user != null) {
					FormsAuthentication.SetAuthCookie(user.Id.ToString(), m.RememberMe) ;
					HttpContext.Session[PiranhaApp.USER] = user ;
					return RedirectToAction("ExecuteUpdate") ;
				} else {
					ViewBag.Message = @Piranha.Resources.Account.MessageLoginFailed ;
					ViewBag.MessageCss = "error" ;
					return Update() ;
				}
			} else {
				ViewBag.Message = @Piranha.Resources.Account.MessageLoginEmptyFields ;
				ViewBag.MessageCss = "" ;
				return Update() ;
			}
		}