# 禁用注册 (/docs/reference/errors/signup_disabled)

禁用注册错误



当你在 OAuth 提供商配置中禁用注册，而用户尝试使用该提供商注册时，会出现此错误。

## 如何修复 [#如何修复]

如果你在无状态模式下使用了 `disableSignUp` 选项，就会看到此错误。请考虑改用数据库钩子来处理此情况。

```ts title="auth.ts"
import { betterAuth } from "better-auth";
import { APIError } from "better-auth/api";

export const auth = betterAuth({
  databaseHooks: {
    user: {
      create: {
        before: async (user, ctx) => {
          const isAllowedToSignUp = await isAllowedToSignUp(user, ctx); // [!code highlight] // 检查用户是否允许注册
          if (!isAllowedToSignUp) {
            throw new APIError("BAD_REQUEST", {
              message: "注册已被禁用",
			});
          },
        },
      },
	},
  }
});
```

