/// <summary> /// 注册账户 /// </summary> /// <param name="Account"></param> /// <param name="Pwd1"></param> /// <param name="Pwd2"></param> /// <returns></returns> public string RegAccount(string Account, string NickName, string Pwd1, string Pwd2) { if (string.IsNullOrEmpty(Account)) { throw new CustomException("账户不应为空"); } if (string.IsNullOrEmpty(Pwd1) || string.IsNullOrEmpty(Pwd2)) { throw new CustomException("请输入密码"); } if (Pwd1 != Pwd2) { throw new CustomException("两次密码不一致"); } if (string.IsNullOrEmpty(NickName)) { throw new CustomException("昵称不应为空"); } IAuthable iAuth = IAuthFac.Create(EnumAuthType.账户密码); if (iAuth.IsExist(Account)) { throw new CustomException("已存在该用户名"); } using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) { string uid = IUser.Add(NickName); iAuth.Bind(new AuthRuest() { Account = Account, Evidence = Pwd1, UserID = uid }); scope.Complete(); return(uid); } }
public UserInfo Query(string Account, string Pwd) { IAuthable iAuth = IAuthFac.Create(EnumAuthType.账户密码); var authR = iAuth.Auth(new AuthRuest() { Account = Account, Evidence = Pwd }); if (authR.Code != AuthCenter.AuthR.Success) { throw new CustomException(authR.ErrorMsg); } UserInfo uInfo = IUser.Find(authR.UserID); if (uInfo == null) { throw new CustomException("数据异常,无法找到该用户信息"); } return(uInfo); }