コード例 #1
0
        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());
        }
コード例 #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));
                }
                else
                {
                    ViewBag.Message    = @Piranha.Resources.Account.MessageLoginFailed;
                    ViewBag.MessageCss = "error";
                }
            }
            else
            {
                ViewBag.Message    = @Piranha.Resources.Account.MessageLoginEmptyFields;
                ViewBag.MessageCss = "";
            }
            return(Index());
        }
コード例 #3
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());
     }
 }