예제 #1
0
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var user = filterContext.HttpContext.Session.GetCurrentUser();
            if (user == null || user.Uid <= 0)
            {
                ICookieService cookieService = new Flh.Web.CookieServiceImpl();
                var cookieUser = cookieService.User;
                if (cookieUser != null)
                {
                    try
                    {
                        IKernel ninjectKernel = new Ninject.StandardKernel(new Ninject.NinjectSettings()
                        {
                            DefaultScopeCallback = ctx => System.Web.HttpContext.Current
                        },
                         new Flh.Business.Inject.DataModule(),
                         new Flh.Business.Inject.ServiceModule()
                         );

                        IUserManager userManager = ninjectKernel.Get<IUserManager>();
                        var userService = userManager.Login(cookieUser.un, cookieUser.pwd, filterContext.HttpContext.Request.GetCurrentIP());
                        var entry = new UserSessionEntry
                          {
                              Name = userService.Name,
                              Uid = userService.Uid
                          };
                        filterContext.HttpContext.Session.SetCurrentUser(entry);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
예제 #2
0
 public static UserSessionEntry Login(this HttpSessionStateBase session, Flh.Business.IUserManager manager, string username, string password, string ip)
 {
     var user = manager.Login(username, password, ip);
     var entry = new UserSessionEntry
     {
         Name = user.Name,
         Uid = user.Uid
     };
     SetCurrentUser(session, entry);
     return entry;
 }
예제 #3
0
        public static UserSessionEntry Login(this HttpSessionStateBase session, Flh.Business.IUserManager manager, string username, string password, string ip)
        {
            var user  = manager.Login(username, password, ip);
            var entry = new UserSessionEntry
            {
                Name = user.Name,
                Uid  = user.Uid
            };

            SetCurrentUser(session, entry);
            return(entry);
        }
예제 #4
0
        public ActionResult Login(Models.Account.LoginModel model)
        {
            if (String.IsNullOrWhiteSpace(model.CertCode)|| String.IsNullOrWhiteSpace(Session.GetCurrentCertCode()) || Session.GetCurrentCertCode().ToLower() != model.CertCode.ToLower())
            {
                Session.SetCurrentCertCode(String.Empty);
                return JsonResult(ErrorCode.ArgError, "验证码错误");
            }
            var admin = _AdminManager.Login(model.UserName, model.Password, Request.GetCurrentIP());

            var entry = new UserSessionEntry
            {
                Name = admin.Name,
                Uid = admin.Uid
            };
            Session.SetCurrentUser(entry);
            return SuccessJsonResult(Request.GetBackUrl());
        }
예제 #5
0
 public static void SetCurrentUser(this HttpSessionStateBase session, UserSessionEntry entry)
 {
     session[Config.Current.SESSION_USER_KEY] = entry;
 }
예제 #6
0
 public static void SetCurrentUser(this HttpSessionStateBase session, UserSessionEntry entry)
 {
     session[Config.Current.SESSION_USER_KEY] = entry;
 }
예제 #7
0
        public ActionResult Login(Models.Account.LoginModel model)
        {
            var user = _UserManager.Login(model.UserName, model.Password, Request.GetCurrentIP());
            var entry = new UserSessionEntry
            {
                Name = user.Name,
                Uid = user.Uid
            };
            Session.SetCurrentUser(entry);

            ICookieService cookieService = new Flh.Web.CookieServiceImpl();
            cookieService.User = new Flh.Web.CookieUser(user.Uid, model.UserName, model.Password, model.Remember);
            return SuccessJsonResult();
        }
예제 #8
0
 protected bool AuthorizeCore(System.Web.HttpContextBase httpContext, UserSessionEntry user)
 {
     return(user != null && user.Uid > 0);
 }
예제 #9
0
 protected bool AuthorizeCore(System.Web.HttpContextBase httpContext, UserSessionEntry user)
 {
     return user != null && user.Uid > 0;
 }