Ejemplo n.º 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)
                    {
                    }
                }
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 5
0
 public static void SetCurrentUser(this HttpSessionStateBase session, UserSessionEntry entry)
 {
     session[Config.Current.SESSION_USER_KEY] = entry;
 }
Ejemplo n.º 6
0
 public static void SetCurrentUser(this HttpSessionStateBase session, UserSessionEntry entry)
 {
     session[Config.Current.SESSION_USER_KEY] = entry;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 8
0
 protected bool AuthorizeCore(System.Web.HttpContextBase httpContext, UserSessionEntry user)
 {
     return(user != null && user.Uid > 0);
 }
Ejemplo n.º 9
0
 protected bool AuthorizeCore(System.Web.HttpContextBase httpContext, UserSessionEntry user)
 {
     return user != null && user.Uid > 0;
 }