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