diff --git a/backend/src/modules/organizations/organizations.service.ts b/backend/src/modules/organizations/organizations.service.ts index e690bbe..0afff92 100644 --- a/backend/src/modules/organizations/organizations.service.ts +++ b/backend/src/modules/organizations/organizations.service.ts @@ -153,6 +153,14 @@ export class OrganizationsService { existing.role = data.role; return this.userOrgRepository.save(existing); } + // Update password for existing user being added to a new org + if (data.password) { + const passwordHash = await bcrypt.hash(data.password, 12); + await dataSource.query( + `UPDATE shared.users SET password_hash = $1 WHERE id = $2`, + [passwordHash, userId], + ); + } } else { // Create new user const passwordHash = await bcrypt.hash(data.password, 12);