Make self-service signup opt-in via SIGNUP_ENABLED
/users/signup answers 403 unless SIGNUP_ENABLED is set. A public GET /utils/config/ tells the login page, which hides the sign-up link, and the signup page explains that an administrator creates accounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
@@ -20,7 +20,11 @@ import {
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { LoadingButton } from "@/components/ui/loading-button"
|
||||
import { PasswordInput } from "@/components/ui/password-input"
|
||||
import useAuth, { isLoggedIn, safeRedirect } from "@/hooks/useAuth"
|
||||
import useAuth, {
|
||||
isLoggedIn,
|
||||
safeRedirect,
|
||||
useSignupEnabled,
|
||||
} from "@/hooks/useAuth"
|
||||
|
||||
const formSchema = z.object({
|
||||
username: z.email(),
|
||||
@@ -55,6 +59,7 @@ export const Route = createFileRoute("/login")({
|
||||
|
||||
function Login() {
|
||||
const { loginMutation } = useAuth()
|
||||
const signupEnabled = useSignupEnabled()
|
||||
const form = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
@@ -132,12 +137,14 @@ function Login() {
|
||||
</LoadingButton>
|
||||
</div>
|
||||
|
||||
<div className="text-center text-sm">
|
||||
Don't have an account yet?{" "}
|
||||
<RouterLink to="/signup" className="underline underline-offset-4">
|
||||
Sign up
|
||||
</RouterLink>
|
||||
</div>
|
||||
{signupEnabled ? (
|
||||
<div className="text-center text-sm">
|
||||
Don't have an account yet?{" "}
|
||||
<RouterLink to="/signup" className="underline underline-offset-4">
|
||||
Sign up
|
||||
</RouterLink>
|
||||
</div>
|
||||
) : null}
|
||||
</form>
|
||||
</Form>
|
||||
</AuthLayout>
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { LoadingButton } from "@/components/ui/loading-button"
|
||||
import { PasswordInput } from "@/components/ui/password-input"
|
||||
import useAuth, { isLoggedIn } from "@/hooks/useAuth"
|
||||
import useAuth, { isLoggedIn, useSignupEnabled } from "@/hooks/useAuth"
|
||||
|
||||
const formSchema = z
|
||||
.object({
|
||||
@@ -59,6 +59,7 @@ export const Route = createFileRoute("/signup")({
|
||||
|
||||
function SignUp() {
|
||||
const { signUpMutation } = useAuth()
|
||||
const signupEnabled = useSignupEnabled()
|
||||
const form = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
@@ -79,6 +80,30 @@ function SignUp() {
|
||||
signUpMutation.mutate(submitData)
|
||||
}
|
||||
|
||||
if (signupEnabled === false) {
|
||||
return (
|
||||
<AuthLayout>
|
||||
<div
|
||||
className="flex flex-col gap-6 text-center"
|
||||
data-testid="signup-disabled"
|
||||
>
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<h1 className="text-2xl font-bold">Sign up is off</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Accounts on this instance are created by an administrator.
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
Already have an account?{" "}
|
||||
<RouterLink to="/login" className="underline underline-offset-4">
|
||||
Log in
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthLayout>
|
||||
<Form {...form}>
|
||||
|
||||
Reference in New Issue
Block a user