コード例 #1
0
        public bool RetrievePwd(JeuciAccount jeuciAccount, string newPassword, string validCodeStr, out string urlOrMsg)
        {
            jeuciAccount.SynchronWechatUserInfo(_wechatAuthentManager);
            jeuciAccount.SynchronUserInfo(_userRepository);
            if (!jeuciAccount.IsExistAccount)
            {
                LogHelper.Logger.Error("获取用户个人信息失败");
                throw new Exception("获取您的个人信息失败,请与我们联系");
            }

            var emialPolicy = new EmailPolicy();
            var validCode   = CacheHelper.GetCache <EmailValidCode>(m_retrievePwdCachePrefix + jeuciAccount.OpenId);

            if (!emialPolicy.ValidEmailCode(validCode, validCodeStr, out urlOrMsg))
            {
                return(false);
            }
            jeuciAccount.UserInfo.Password = newPassword;
            try
            {
                _userRepository.Update(jeuciAccount.UserInfo);
                urlOrMsg = string.Format("/wechat/account/#/wechatforjeuci?isNeedCallBack=False&openId={0}", jeuciAccount.OpenId);
                return(true);
            }
            catch (Exception e)
            {
                urlOrMsg = e.Message;
                return(false);
            }
        }
コード例 #2
0
        public bool BindUserEmail(BindEmailModel model, out string msgOrUrl)
        {
            var validCode = CacheHelper.GetCache <EmailValidCode>(model.OpenId);

            if (validCode == null)
            {
                LogHelper.Logger.Info("缓存过期,没有获取到电子邮件验证码");
                throw new Exception("验证码超时,请重新获取电子邮件验证码");
            }
            var bindEmailPolicy = new EmailPolicy();

            if (!bindEmailPolicy.ValidEmailCode(validCode, model.ValidCode, out msgOrUrl))
            {
                return(false);
            }
            var jeuciAccount = new JeuciAccount(model.OpenId, model.AccountName, model.Password, AccountOperateType.BindEmail);

            jeuciAccount.SynchronUserInfo(_useRepository);
            var jueciAccountPolicy = new JeuciAccountPolicy(jeuciAccount);

            if (!jueciAccountPolicy.ValidAccountLegality(out msgOrUrl))
            {
                return(false);
            }

            jeuciAccount.UserInfo.SafeEmail = model.SafeEmail;
            try
            {
                _useRepository.Update(jeuciAccount.UserInfo);
                msgOrUrl = string.Format("/wechat/account/#/wechatforjeuci?isNeedCallBack=False&openId={0}", model.OpenId);
                return(true);
            }
            catch (Exception e)
            {
                msgOrUrl = e.Message;
                return(false);
            }
        }