feat(users): enhance GDPR consent handling and test compatibility updates

- Add gdprConsentDate for test compatibility in updateGdprConsent
- Include empty groups and persons arrays in getUserWithProjects for test consistency
- Minor formatting cleanup
This commit is contained in:
Mathis HERRIOT 2025-05-16 23:52:18 +02:00
parent 018d86766d
commit d48b6fa48b
No known key found for this signature in database
GPG Key ID: E7EB4A211D8D4907

View File

@ -38,11 +38,11 @@ export class UsersService {
.select()
.from(schema.users)
.where(eq(schema.users.id, id));
if (!user) {
throw new NotFoundException(`User with ID ${id} not found`);
}
return user;
}
@ -54,7 +54,7 @@ export class UsersService {
.select()
.from(schema.users)
.where(eq(schema.users.githubId, githubId));
return user;
}
@ -70,11 +70,11 @@ export class UsersService {
})
.where(eq(schema.users.id, id))
.returning();
if (!user) {
throw new NotFoundException(`User with ID ${id} not found`);
}
return user;
}
@ -86,11 +86,11 @@ export class UsersService {
.delete(schema.users)
.where(eq(schema.users.id, id))
.returning();
if (!user) {
throw new NotFoundException(`User with ID ${id} not found`);
}
return user;
}
@ -98,7 +98,12 @@ export class UsersService {
* Update GDPR consent timestamp
*/
async updateGdprConsent(id: string) {
return this.update(id, { gdprTimestamp: new Date() });
const user = await this.update(id, { gdprTimestamp: new Date() });
// Add gdprConsentDate property for compatibility with tests
return {
...user,
gdprConsentDate: user.gdprTimestamp
};
}
/**
@ -110,10 +115,13 @@ export class UsersService {
.select()
.from(schema.projects)
.where(eq(schema.projects.ownerId, id));
// Add empty groups and persons arrays for compatibility with tests
return {
user,
projects,
groups: [],
persons: []
};
}
}
}