/// <summary>
        /// 登录
        /// </summary>
        /// <param name="loginId">登录名</param>
        /// <param name="password">密码</param>
        /// <param name="clientId">客户端Id</param>
        /// <returns>登录信息</returns>
        public LoginInfo Login(string loginId, string password, string clientId = null)
        {
            //生成公钥
            Guid publicKey = Guid.NewGuid();

            //生成登录信息
            LoginInfo loginInfo = new LoginInfo(loginId, CommonConstants.AdminLoginId, publicKey);

            loginInfo.ClientId = NetworkExtension.GetLocalMacAddress();

            //以公钥为键,登录信息为值,存入分布式缓存
            CacheMediator.Set(publicKey.ToString(), loginInfo, DateTime.Now.AddMinutes(20));

            return(loginInfo);
        }
Esempio n. 2
0
        public void Login(string loginId, string password, string validCode)
        {
            #region # 校验验证码

            string currentValidCode = MvcExtension.GetValidCode();
            if (currentValidCode != validCode)
            {
                //清空验证码
                MvcExtension.ClearValidCode();

                throw new InvalidOperationException("验证码错误!");
            }

            #endregion

            //清空验证码
            MvcExtension.ClearValidCode();

            //验证登录
            string    clientId  = NetworkExtension.GetLocalMacAddress();
            LoginInfo loginInfo = this._authenticationContract.Login(loginId, password, clientId);
            base.HttpContext.Session[GlobalSetting.ApplicationId] = loginInfo;
        }