Skip to content

Commit 62a380d

Browse files
author
Jovinull
committed
feat(api): adiciona e persiste role de usuario no registro
1 parent 382d321 commit 62a380d

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

backend/src/modules/auth/credentials.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class CredentialsService {
3232
async register(
3333
input: RegisterInput,
3434
): Promise<{ user: User; session: Session }> {
35-
const { email, password, name, phone, cpf, technologies, level } = RegisterSchema.parse(input);
35+
const { email, password, name, phone, cpf, technologies, level, role } = RegisterSchema.parse(input);
3636

3737
const existingCredential = await db.query.credentials.findFirst({
3838
where: eq(credentials.email, email),
@@ -57,7 +57,8 @@ export class CredentialsService {
5757
phone,
5858
cpf,
5959
technologies,
60-
level
60+
level,
61+
role
6162
})
6263
.returning();
6364

backend/src/modules/types/credentials.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const RegisterSchema = z.object({
88
cpf: z.string().optional(),
99
technologies: z.array(z.string()).optional(),
1010
level: z.string().optional(),
11+
role: z.enum(["user", "admin"]).optional().default("user"),
1112
});
1213

1314
export const LoginSchema = z.object({

0 commit comments

Comments
 (0)