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); } }
public bool ModifyPassword(JeuciAccount jeuciAccount, string newPassworld, out string urlOrMsg) { jeuciAccount.SynchronWechatUserInfo(_wechatAuthentManager); jeuciAccount.SynchronUserInfo(_userRepository); if (!jeuciAccount.IsExistAccount) { LogHelper.Logger.Error("获取用户个人信息失败"); throw new Exception("获取您的个人信息失败,请与我们联系"); } if (!jeuciAccount.IsValidPassword) { urlOrMsg = "您输入的密码不正确,请重新输入!"; return(false); } jeuciAccount.UserInfo.Password = newPassworld; 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); } }
public JeuciAccount GetWechatUserInfo(string openId) { var jeuciAccount = new JeuciAccount(openId, AccountOperateType.ObtainAccount); jeuciAccount.SynchronWechatUserInfo(_wechatAuthentManager); jeuciAccount.SynchronUserInfo(_userRepository); return(jeuciAccount); }
public bool UnbindWechatAccount(JeuciAccount jeuciAccount, out string urlOrMsg) { jeuciAccount.SynchronWechatUserInfo(_wechatAuthentManager); jeuciAccount.SynchronUserInfo(_userRepository); var accountPolicy = new JeuciAccountPolicy(jeuciAccount); if (!accountPolicy.ValidCanUnbindAccount(out urlOrMsg)) { return(false); } return(accountPolicy.UnBindWechatAccount(_userRepository, out urlOrMsg)); }
public bool BindWechatAccount(JeuciAccount account, out string urlOrMsg) { //1.判断用户输入的账号是否存在 //2.微信号是否已经被绑定 account.SynchronWechatUserInfo(_wechatAuthentManager); account.SynchronUserInfo(_userRepository); var accountPolicy = new JeuciAccountPolicy(account); if (!accountPolicy.ValidAccountLegality(out urlOrMsg)) { return(false); } return(accountPolicy.BindWechatAccount(_userRepository, out urlOrMsg)); }
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); } }
public JeuciAccountPolicy(JeuciAccount account) { this._account = account; }