public Result ActiveAccount(string account, string code) { Result Result = new Result(); try { User user = UserService.GetUser(account); if (user == null) { throw new Exception("用户名错误不存在!"); } if (UserService.ActiveAccount(account, code, false)) { Result.Data = "激活成功!"; } else { throw new Exception("激活失败,激活码错误!"); } } catch (Exception ex) { Result.Msg = ex.Message; Result.SetFail(); } return(Result); }
public Result Register(string account, string password, string code, string email, string recommend) { Result obj = new Result(); try { string value = CacheOption.GetValue <string>("register_{0}".ToFormat(account)); if (string.IsNullOrEmpty(value)) { throw new Exception("该账号没有被发送过邮箱验证,请在发送邮箱验证之后不要" + "更改填写的账号!"); } if (!value.Equals(code)) { throw new Exception("验证码错误,请检查发送到指定邮箱的验证码!"); } User user = new User() { Name = account, Password = MD5Comm.Get32MD5One(password), Email = email, Level = 0, CreateTime = DateTime.Now, }; obj.SetCode(UserService.AddUser(user) ? ResultCode.Success : ResultCode.Fail); try { UserService.ActiveAccount(user.Name, recommend, true); } catch (Exception) { } } catch (Exception ex) { obj.Msg = ex.Message; obj.SetCode(ResultCode.Fail); } return(obj); }