示例#1
0
 public AccountController(IMemberService memberService, IAcountService acountService)
 {
     this.memberService = memberService;
     this.acountService = acountService;
 }
 public LoginController(IJWTAuthentication jwtAuthenticationManager, IAcountService acountService, IUserService userService)
 {
     this._acountService            = acountService;
     this._jwtAuthenticationManager = jwtAuthenticationManager;
     this._userService = userService;
 }
示例#3
0
 public TestController(IJWTAuthentication jwtAuthenticationManager, IAcountService acountService)
 {
     this.jwtAuthenticationManager = jwtAuthenticationManager;
     this._acountService           = acountService;
 }
示例#4
0
 public EnterpriseService(CVManagerDBContext dbContext, IAcountService acountService)
 {
     this._acountService = acountService;
     this._dbContext     = dbContext;
 }
示例#5
0
 public EnterPriseLoginController(IJWTAuthentication jwtAuthenticationManager, IAcountService acountService, IEnterpriseService enterpriseService)
 {
     this._acountService            = acountService;
     this._jwtAuthenticationManager = jwtAuthenticationManager;
     this._enterpriseService        = enterpriseService;
 }
示例#6
0
 public MemberService(IMemberRepository memberRepository, IAcountRepository acountRepository, IAcountService acountService)
 {
     this.memberRepository = memberRepository;
     this.acountRepository = acountRepository;
     this.acountService    = acountService;
 }
示例#7
0
        private static Logger logger = new Logger(typeof(UserManager)); //Logger.CreateLogger(typeof(UserManager));
        /// <summary>
        /// 用户登录验证
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <param name="verifyCode"></param>
        /// <returns></returns>
        public static LoginResult Login(this HttpContextBase context, string name, string password, string verifyCode)
        {
            if (context.Session["CheckCode"] != null &&
                !string.IsNullOrWhiteSpace(context.Session["CheckCode"].ToString()) &&
                context.Session["CheckCode"].ToString().Equals(verifyCode, StringComparison.CurrentCultureIgnoreCase))
            {
                using (IAcountService servcie = DIFactory.GetContainer().Resolve <IAcountService>())
                {
                    Acount user = servcie.Set <Acount>().FirstOrDefault(u => u.name.Equals(name) || u.account.Equals(name));//账号查找
                    if (user == null)
                    {
                        return(LoginResult.NoUser);
                    }
                    //else if (!user.password.Equals(MD5Encrypt.Encrypt(password)))
                    else if (!user.password.Equals(password))
                    {
                        return(LoginResult.WrongPwd);
                    }
                    //else if (user.State == 1)
                    //{
                    //    return LoginResult.Frozen;
                    //}
                    else
                    {
                        //登录成功  写cookie session
                        CurrentLoginUser currentUser = new CurrentLoginUser()
                        {
                            Id        = user.id,
                            Name      = user.name,
                            Account   = user.account,
                            Email     = user.email,
                            Password  = user.password,
                            LoginTime = DateTime.Now
                        };

                        //都是asp.net解析的
                        #region Request
                        //context.Request.Headers["User-Agent"];
                        //context.Request["Refer"];
                        //context.Request
                        //Request 获取请求个各种参数,
                        //Header里面的各种信息
                        //InputStream上传的文件
                        #endregion

                        #region Response
                        //context.Response
                        //Response响应的 跨域、压缩、缓存、cookie、output + contentType
                        #endregion

                        #region Application
                        context.Application.Lock(); //ASP.NET 应用程序内的多个会话和请求之间共享信息
                        context.Application.Lock(); //操作之前加锁
                        context.Application.Add("try", "die");
                        context.Application.UnLock();
                        object aValue = context.Application.Get("try");
                        aValue = context.Application["try"];
                        context.Application.Remove("命名对象");
                        context.Application.RemoveAt(0);
                        context.Application.RemoveAll();
                        context.Application.Clear();
                        #endregion

                        #region Items

                        context.Items["123"] = "123";//单一会话,不同环境都可以用,比如在httpmodule获取到的信息,想传递给action;随着context释放
                        #endregion

                        #region Server
                        //辅助类 Server
                        string encode = context.Server.HtmlEncode("<我爱我家>");
                        string decode = context.Server.HtmlDecode(encode);

                        string physicalPath = context.Server.MapPath("/Home/Index");//只能做物理文件的映射
                        string encodeUrl    = context.Server.UrlEncode("<我爱我家>");
                        string decodeUrl    = context.Server.UrlDecode(encodeUrl);
                        #endregion

                        #region Cookie
                        //context.Request.Cookies

                        //HttpCookie cookie = context.Request.Cookies.Get("CurrentUser");
                        //if (cookie == null)
                        //{
                        HttpCookie myCookie = new HttpCookie("CurrentUser");
                        myCookie.Value   = JsonHelper.ObjectToString <CurrentLoginUser>(currentUser);
                        myCookie.Expires = DateTime.Now.AddMinutes(5);//保存到硬盘

                        //5分钟后  硬盘cookie
                        //不设置就是内存cookie--关闭浏览器就丢失
                        //改成过期 -1 过期
                        //修改cookie:不能修改,只能起个同名的cookie

                        //myCookie.Domain//设置cookie共享域名
                        //myCookie.Path//指定路径能享有cookie
                        context.Response.Cookies.Add(myCookie);//一定要输出
                        //}
                        //前端只能获取name-value
                        #endregion Cookie

                        #region Session
                        //context.Session.RemoveAll();
                        var sessionUser = context.Session["CurrentUser"];
                        context.Session["CurrentUser"] = currentUser;
                        context.Session.Timeout        = 3;//minute  session过期等于Abandon
                        #endregion Session

                        logger.Debug(string.Format("用户id={0} Name={1}登录系统", currentUser.Id, currentUser.Name));
                        return(LoginResult.Success);
                    }
                }
            }
            else
            {
                return(LoginResult.WrongVerify);
            }
        }
示例#8
0
 public AcountController(IAcountService acountServices)
 {
     _acountServices = acountServices;
 }
示例#9
0
 public AcountController(IAcountService acountService)
 {
     this._acountService = acountService;
 }