feat: implement configuration management and enhance user registration flow
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { useLogin } from "@/hooks/use-auth";
|
||||
import { useConfig } from "@/hooks/use-channels";
|
||||
|
||||
export default function LoginPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const { mutate: login, isPending, error } = useLogin();
|
||||
const { data: config } = useConfig();
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -63,12 +65,14 @@ export default function LoginPage() {
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p className="text-center text-xs text-zinc-500">
|
||||
No account?{" "}
|
||||
<Link href="/register" className="text-zinc-300 hover:text-white">
|
||||
Create one
|
||||
</Link>
|
||||
</p>
|
||||
{config?.allow_registration !== false && (
|
||||
<p className="text-center text-xs text-zinc-500">
|
||||
No account?{" "}
|
||||
<Link href="/register" className="text-zinc-300 hover:text-white">
|
||||
Create one
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,27 @@
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { useRegister } from "@/hooks/use-auth";
|
||||
import { useConfig } from "@/hooks/use-channels";
|
||||
|
||||
export default function RegisterPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const { mutate: register, isPending, error } = useRegister();
|
||||
const { data: config } = useConfig();
|
||||
|
||||
if (config && !config.allow_registration) {
|
||||
return (
|
||||
<div className="w-full max-w-sm space-y-4 text-center">
|
||||
<h1 className="text-xl font-semibold text-zinc-100">Registration disabled</h1>
|
||||
<p className="text-sm text-zinc-500">
|
||||
The administrator has disabled new account registration.
|
||||
</p>
|
||||
<Link href="/login" className="inline-block text-sm text-zinc-300 hover:text-white">
|
||||
Sign in instead
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user