feat(admin-auth): support username login and add dashboard logout
This commit is contained in:
@@ -31,6 +31,7 @@ export function LoginForm({ mode }: LoginFormProps) {
|
||||
const nextPath = useMemo(() => searchParams.get("next") || "/", [searchParams])
|
||||
|
||||
const [name, setName] = useState("Admin User")
|
||||
const [username, setUsername] = useState("")
|
||||
const [email, setEmail] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [isBusy, setIsBusy] = useState(false)
|
||||
@@ -50,7 +51,7 @@ export function LoginForm({ mode }: LoginFormProps) {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
identifier: email,
|
||||
password,
|
||||
callbackURL: nextPath,
|
||||
}),
|
||||
@@ -93,6 +94,7 @@ export function LoginForm({ mode }: LoginFormProps) {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
username,
|
||||
email,
|
||||
password,
|
||||
callbackURL: nextPath,
|
||||
@@ -152,11 +154,11 @@ export function LoginForm({ mode }: LoginFormProps) {
|
||||
>
|
||||
<div className="space-y-1">
|
||||
<label className="text-sm font-medium" htmlFor="email">
|
||||
Email
|
||||
Email or username
|
||||
</label>
|
||||
<input
|
||||
id="email"
|
||||
type="email"
|
||||
type="text"
|
||||
required
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
@@ -228,6 +230,19 @@ export function LoginForm({ mode }: LoginFormProps) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<label className="text-sm font-medium" htmlFor="username">
|
||||
Username (optional)
|
||||
</label>
|
||||
<input
|
||||
id="username"
|
||||
type="text"
|
||||
value={username}
|
||||
onChange={(event) => setUsername(event.target.value)}
|
||||
className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<label className="text-sm font-medium" htmlFor="password">
|
||||
Password
|
||||
|
||||
Reference in New Issue
Block a user