ENCOA-308

This commit is contained in:
Carlos-Mesquita
2025-01-05 19:04:08 +00:00
parent 0739e044a1
commit 61e07dae95
2 changed files with 19 additions and 20 deletions

View File

@@ -38,7 +38,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
passport_id?: string;
phone: string;
};
entity?: string
entity: { id: string, label: string }
entities: { id: string, role: string }[]
passwordHash: string | undefined;
passwordSalt: string | undefined;
@@ -49,11 +49,10 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
const salt = crypto.randomBytes(16).toString('base64');
const hash = await scrypt.hash(user.passport_id, salt);
const entity = await getEntityWithRoles(currentUser.entity!)
const entity = await getEntityWithRoles(currentUser.entity!.id)
const defaultRole = findBy(entity?.roles || [], "isDefault", true)
currentUser.entities = [{ id: entity?.id || "", role: defaultRole?.id || "" }]
delete currentUser.entity
currentUser.email = currentUser.email.toLowerCase();
currentUser.passwordHash = hash;