feat: add company selection to user dialog, require email password link on user creation, password validation with confirmation, and company grouping with search
Some checks failed
Staging Build / build (push) Failing after 25s
Some checks failed
Staging Build / build (push) Failing after 25s
This commit is contained in:
@@ -20,6 +20,7 @@ export function UpdatePasswordForm({
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<"div">) {
|
||||
const [password, setPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const router = useRouter();
|
||||
@@ -29,11 +30,23 @@ export function UpdatePasswordForm({
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
|
||||
if (password.length < 6) {
|
||||
setError("Passwort muss mindestens 6 Zeichen lang sein.");
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
setError("Die Passwörter stimmen nicht überein.");
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await updatePassword(password);
|
||||
router.push("/");
|
||||
} catch (error: unknown) {
|
||||
setError(error instanceof Error ? error.message : "An error occurred");
|
||||
setError(error instanceof Error ? error.message : "Ein Fehler ist aufgetreten");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -41,30 +54,43 @@ export function UpdatePasswordForm({
|
||||
|
||||
return (
|
||||
<div className={cn("flex flex-col gap-6", className)} {...props}>
|
||||
<Card>
|
||||
<Card className="glass-dark border-white/10 text-white shadow-2xl">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-2xl">Reset Your Password</CardTitle>
|
||||
<CardDescription>
|
||||
Please enter your new password below.
|
||||
<CardTitle className="text-2xl">Neues Passwort festlegen</CardTitle>
|
||||
<CardDescription className="text-slate-300">
|
||||
Bitte geben Sie Ihr neues Passwort ein und bestätigen Sie es.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleForgotPassword}>
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="password">New password</Label>
|
||||
<Label htmlFor="password">Neues Passwort</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="New password"
|
||||
placeholder="Neues Passwort"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
className="bg-white/5 border-white/10 text-white"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="confirmPassword">Passwort bestätigen</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
placeholder="Passwort bestätigen"
|
||||
required
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
className="bg-white/5 border-white/10 text-white"
|
||||
/>
|
||||
</div>
|
||||
{error && <p className="text-sm text-red-500">{error}</p>}
|
||||
<Button type="submit" className="w-full" disabled={isLoading}>
|
||||
{isLoading ? "Saving..." : "Save new password"}
|
||||
<Button type="submit" className="w-full bg-primary hover:bg-primary/90" disabled={isLoading}>
|
||||
{isLoading ? "Speichern..." : "Neues Passwort speichern"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user