コード例 #1
0
        public ActionResult Login(FormCollection form)
        {
            //Session["BurgerStatus"] = "Opened";
            //HttpCookie cokie = new HttpCookie("NavBar");
            //cokie.Value = "NavBar=Opened";

            String username = form["username"].ToString();
            String password = form["password"].ToString();
            String role     = form["dataRole"].ToString();
            int    roleId   = Int32.Parse(role);

            User usr = GetUserData(username, password, roleId);

            if (usr != null)
            {
                Session["username"]    = usr.Username;
                Session["role"]        = usr.Role.RoleName;
                Session["DisplayName"] = usr.DisplayName;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                OanTechLog.Info("Invalid Login Attemp for Username: "******".");
                ViewBag.Message = "Invalid Login Attemp!";
                return(RedirectToAction("Login", "Account"));
            }
        }
コード例 #2
0
        public ActionResult Login(FormCollection form)
        {
            //Session["BurgerStatus"] = "Opened";
            //HttpCookie cokie = new HttpCookie("NavBar");
            //cokie.Value = "NavBar=Opened";

            String userlogin = form["userlogin"].ToString();
            String userpin   = form["userpin"].ToString();
            String role      = form["dataRole"].ToString();
            Int64  roleId    = Int64.Parse(role);

            User usr = obj.GetUserData(userlogin, userpin, roleId);

            if (usr != null)
            {
                Session["UserId"]        = usr.UserId;
                Session["Role"]          = obj.GetUserRole(roleId).RoleName;
                Session["DisplayName"]   = usr.DisplayName;
                Session["SecurityToken"] = obj.GenerateSecurityToken(usr.UserId);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                OanTechLog.Info("Invalid Login Attemp for User: "******".");
                ViewBag.Message = "Invalid Login Attemp!";
                return(RedirectToAction("Login", "Account"));
            }
        }