refactor: remove 'mustChangePassword' field from user forms and related logic
This commit is contained in:
parent
25d75825be
commit
94b603b83c
3 changed files with 1 additions and 30 deletions
|
|
@ -12,7 +12,6 @@ import {
|
||||||
import Input from "~/components/custom_ui/input";
|
import Input from "~/components/custom_ui/input";
|
||||||
import { PhoneInput } from "~/components/phone-input";
|
import { PhoneInput } from "~/components/phone-input";
|
||||||
import { Button, buttonVariants } from "~/components/ui/button";
|
import { Button, buttonVariants } from "~/components/ui/button";
|
||||||
import { Switch } from "~/components/ui/switch";
|
|
||||||
import { useStrongPassword } from "~/hooks/useStrongPassword";
|
import { useStrongPassword } from "~/hooks/useStrongPassword";
|
||||||
import { generatePassword } from "~/lib/basicPwGenerator";
|
import { generatePassword } from "~/lib/basicPwGenerator";
|
||||||
import { cn } from "~/lib/utils";
|
import { cn } from "~/lib/utils";
|
||||||
|
|
@ -41,7 +40,6 @@ export const FormNewUser = ({
|
||||||
nome: z.string().nonempty("Inserisci un nome valido"),
|
nome: z.string().nonempty("Inserisci un nome valido"),
|
||||||
password: z.string(),
|
password: z.string(),
|
||||||
telefono: z.string().nonempty("Inserisci un numero di telefono"),
|
telefono: z.string().nonempty("Inserisci un numero di telefono"),
|
||||||
mustChangePassword: z.boolean(),
|
|
||||||
})
|
})
|
||||||
.superRefine(({ password }, refinementContext) => {
|
.superRefine(({ password }, refinementContext) => {
|
||||||
passwordRefine({
|
passwordRefine({
|
||||||
|
|
@ -59,7 +57,6 @@ export const FormNewUser = ({
|
||||||
nome: "",
|
nome: "",
|
||||||
password: "",
|
password: "",
|
||||||
telefono: "",
|
telefono: "",
|
||||||
mustChangePassword: true,
|
|
||||||
};
|
};
|
||||||
const { locale, t } = useTranslation();
|
const { locale, t } = useTranslation();
|
||||||
|
|
||||||
|
|
@ -89,7 +86,6 @@ export const FormNewUser = ({
|
||||||
nome: fields.nome,
|
nome: fields.nome,
|
||||||
password: fields.password,
|
password: fields.password,
|
||||||
telefono: fields.telefono.replace(/\s/g, ""),
|
telefono: fields.telefono.replace(/\s/g, ""),
|
||||||
mustChangePassword: fields.mustChangePassword,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,28 +222,7 @@ export const FormNewUser = ({
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="mustChangePassword"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full">
|
|
||||||
<div className="flex flex-wrap items-center gap-x-2">
|
|
||||||
<FormLabel htmlFor="mustChangePassword">
|
|
||||||
Forza cambio password al prossimo accesso
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Switch
|
|
||||||
checked={field.value}
|
|
||||||
className="data-[state=checked]:bg-neutral-700"
|
|
||||||
id="mustChangePassword"
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</div>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="telefono"
|
name="telefono"
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ export const authRouter = createTRPCRouter({
|
||||||
nome: z.string().nonempty("Inserisci un nome valido"),
|
nome: z.string().nonempty("Inserisci un nome valido"),
|
||||||
password: zStrongPassword,
|
password: zStrongPassword,
|
||||||
telefono: z.string().nonempty("Inserisci un numero di telefono"),
|
telefono: z.string().nonempty("Inserisci un numero di telefono"),
|
||||||
mustChangePassword: z.boolean(),
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,12 @@ export const createUserAdmin = async ({
|
||||||
nome,
|
nome,
|
||||||
cognome,
|
cognome,
|
||||||
telefono,
|
telefono,
|
||||||
mustChangePassword,
|
|
||||||
}: {
|
}: {
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
nome: string;
|
nome: string;
|
||||||
cognome: string;
|
cognome: string;
|
||||||
telefono: string;
|
telefono: string;
|
||||||
mustChangePassword: boolean;
|
|
||||||
}) => {
|
}) => {
|
||||||
const banned = await isBanned({ data: { email }, db });
|
const banned = await isBanned({ data: { email }, db });
|
||||||
if (banned) {
|
if (banned) {
|
||||||
|
|
@ -53,7 +51,6 @@ export const createUserAdmin = async ({
|
||||||
isAdminMade: true,
|
isAdminMade: true,
|
||||||
nome: nome.trim(),
|
nome: nome.trim(),
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
mustChangePassword,
|
|
||||||
salt,
|
salt,
|
||||||
telefono,
|
telefono,
|
||||||
username: `${nome.trim()} ${cognome.trim()}`,
|
username: `${nome.trim()} ${cognome.trim()}`,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue