Exemplo n.º 1
0
        public ActionResult LogOn(string logOnKey)
        {
            UserLoginInfo userLoginInfo = (new JavaScriptSerializer()).Deserialize <UserLoginInfo>(Des.DecryptDES(logOnKey, "12345678"));
            string        userName      = userLoginInfo.UserName;
            string        password      = userLoginInfo.Password;
            string        cityId        = userLoginInfo.CityID;
            string        systemId      = userLoginInfo.SystemID;
            string        serverId      = userLoginInfo.ServerID;
            bool          bResult       = UserService.ValidateUser(userName, password) &&
                                          UserService.ValidateUserPermission(userName, cityId, systemId);

            if (bResult)
            {
                FormsService.SignIn(userName, false);
                this.AddCookie("cityid", cityId);
                this.AddCookie("systemid", systemId);
                this.AddCookie("serverid", serverId);
                this.AddCookie("username", userName);
                string nowTime  = DateTime.Now.ToString();
                string ipAdress = this.ControllerContext.HttpContext.Request.UserHostAddress;
                if (!UserService.CheckAdress(userName, ipAdress) && UserService.GetUserIp(userName) != "")
                {
                    LoginLogService.UpdateLoginLog(userName, nowTime);
                }
                LoginLogService.CreateLoginLog(nowTime, userName, Guid.Parse(systemId), ipAdress);
                UserService.UpdateUserInfo(userName, ipAdress);
            }
            return(new RedirectToRouteResult(new RouteValueDictionary {
                { "controller", "Home" }
            }));
        }
Exemplo n.º 2
0
        public ActionResult LogOn(string logOnKey)
        {
            UserLoginInfo userLoginInfo = (new JavaScriptSerializer()).Deserialize <UserLoginInfo>(Des.DecryptDES(logOnKey, "12345678"));
            string        userName      = userLoginInfo.UserName;
            string        password      = userLoginInfo.Password;
            string        cityId        = userLoginInfo.CityID;
            string        systemId      = userLoginInfo.SystemID;
            string        serverId      = userLoginInfo.ServerID;
            bool          bResult       = UserService.ValidateUser(userName, password) &&
                                          UserService.ValidateUserPermission(userName, cityId, systemId);

            if (bResult)
            {
                FormsService.SignIn(userName, false);
                this.AddCookie("cityid", cityId);
                this.AddCookie("systemid", systemId);
                this.AddCookie("serverid", serverId);
            }
            return(new RedirectToRouteResult(new RouteValueDictionary {
                { "controller", "Home" }
            }));
        }