Example #1
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                Account acc;
                try
                {
                    IAuthService auth = new AuthService();
                    acc = auth.Login(model.UserName, model.Password);
                }
                catch (ApplicationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return View(model);
                }
                LoginInfo cp = new LoginInfo(this.HttpContext);
                cp.RoleId = acc.Role;
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            return View(model);
        }
Example #2
0
 public ActionResult Index()
 {
     LoginInfo loginInfo = new LoginInfo(this.HttpContext);
     if (loginInfo.RoleId == 1)
         return RedirectToAction("IndexManager", "Pegawai");
     return View(pegawaiReportRepo.GetAll());
 }
Example #3
0
 public ActionResult Index()
 {
     LoginInfo loginInfo = new LoginInfo(this.HttpContext);
     if (loginInfo.RoleId == 1)
         return RedirectToAction("Index", "Report");
     IList<Maskapai> maskapai = maskapaiRepo.GetAllMaskapai();
     ViewBag.Gate = gateRepo.GetAllGate();
     return View(maskapai);
 }