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 { PhoneInput } from "~/components/phone-input";
|
||||
import { Button, buttonVariants } from "~/components/ui/button";
|
||||
import { Switch } from "~/components/ui/switch";
|
||||
import { useStrongPassword } from "~/hooks/useStrongPassword";
|
||||
import { generatePassword } from "~/lib/basicPwGenerator";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
|
@ -41,7 +40,6 @@ export const FormNewUser = ({
|
|||
nome: z.string().nonempty("Inserisci un nome valido"),
|
||||
password: z.string(),
|
||||
telefono: z.string().nonempty("Inserisci un numero di telefono"),
|
||||
mustChangePassword: z.boolean(),
|
||||
})
|
||||
.superRefine(({ password }, refinementContext) => {
|
||||
passwordRefine({
|
||||
|
|
@ -59,7 +57,6 @@ export const FormNewUser = ({
|
|||
nome: "",
|
||||
password: "",
|
||||
telefono: "",
|
||||
mustChangePassword: true,
|
||||
};
|
||||
const { locale, t } = useTranslation();
|
||||
|
||||
|
|
@ -89,7 +86,6 @@ export const FormNewUser = ({
|
|||
nome: fields.nome,
|
||||
password: fields.password,
|
||||
telefono: fields.telefono.replace(/\s/g, ""),
|
||||
mustChangePassword: fields.mustChangePassword,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -226,28 +222,7 @@ export const FormNewUser = ({
|
|||
</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
|
||||
control={form.control}
|
||||
name="telefono"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ export const authRouter = createTRPCRouter({
|
|||
nome: z.string().nonempty("Inserisci un nome valido"),
|
||||
password: zStrongPassword,
|
||||
telefono: z.string().nonempty("Inserisci un numero di telefono"),
|
||||
mustChangePassword: z.boolean(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input }) => {
|
||||
|
|
|
|||
|
|
@ -26,14 +26,12 @@ export const createUserAdmin = async ({
|
|||
nome,
|
||||
cognome,
|
||||
telefono,
|
||||
mustChangePassword,
|
||||
}: {
|
||||
email: string;
|
||||
password: string;
|
||||
nome: string;
|
||||
cognome: string;
|
||||
telefono: string;
|
||||
mustChangePassword: boolean;
|
||||
}) => {
|
||||
const banned = await isBanned({ data: { email }, db });
|
||||
if (banned) {
|
||||
|
|
@ -53,7 +51,6 @@ export const createUserAdmin = async ({
|
|||
isAdminMade: true,
|
||||
nome: nome.trim(),
|
||||
password: hashedPassword,
|
||||
mustChangePassword,
|
||||
salt,
|
||||
telefono,
|
||||
username: `${nome.trim()} ${cognome.trim()}`,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue