@blackcode_sa/metaestetics-api 1.12.56 → 1.12.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3846,6 +3846,11 @@ var AUTH_ERRORS = {
3846
3846
  "AUTH/INVALID_ROLE",
3847
3847
  400
3848
3848
  ),
3849
+ UNAUTHORIZED_ROLE: new AuthError(
3850
+ "You do not have permission to access the clinic application. This account is registered as a patient. Please use the mobile app to access your patient account.",
3851
+ "AUTH/UNAUTHORIZED_ROLE",
3852
+ 403
3853
+ ),
3849
3854
  // Authentication errors
3850
3855
  NOT_AUTHENTICATED: new AuthError(
3851
3856
  "User is not authenticated",
@@ -11596,7 +11601,8 @@ var AuthService = class extends BaseService {
11596
11601
  const user = await this.userService.getOrCreateUser(firebaseUser);
11597
11602
  if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
11598
11603
  console.error("[AUTH] User is not a clinic admin:", user.uid);
11599
- throw AUTH_ERRORS.INVALID_ROLE;
11604
+ await this.auth.signOut();
11605
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
11600
11606
  }
11601
11607
  if (!user.adminProfile) {
11602
11608
  console.error("[AUTH] User has no admin profile:", user.uid);
package/dist/index.mjs CHANGED
@@ -3764,6 +3764,11 @@ var AUTH_ERRORS = {
3764
3764
  "AUTH/INVALID_ROLE",
3765
3765
  400
3766
3766
  ),
3767
+ UNAUTHORIZED_ROLE: new AuthError(
3768
+ "You do not have permission to access the clinic application. This account is registered as a patient. Please use the mobile app to access your patient account.",
3769
+ "AUTH/UNAUTHORIZED_ROLE",
3770
+ 403
3771
+ ),
3767
3772
  // Authentication errors
3768
3773
  NOT_AUTHENTICATED: new AuthError(
3769
3774
  "User is not authenticated",
@@ -11695,7 +11700,8 @@ var AuthService = class extends BaseService {
11695
11700
  const user = await this.userService.getOrCreateUser(firebaseUser);
11696
11701
  if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
11697
11702
  console.error("[AUTH] User is not a clinic admin:", user.uid);
11698
- throw AUTH_ERRORS.INVALID_ROLE;
11703
+ await this.auth.signOut();
11704
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
11699
11705
  }
11700
11706
  if (!user.adminProfile) {
11701
11707
  console.error("[AUTH] User has no admin profile:", user.uid);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.12.56",
4
+ "version": "1.12.57",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -26,6 +26,11 @@ export const AUTH_ERRORS = {
26
26
  "AUTH/INVALID_ROLE",
27
27
  400
28
28
  ),
29
+ UNAUTHORIZED_ROLE: new AuthError(
30
+ "You do not have permission to access the clinic application. This account is registered as a patient. Please use the mobile app to access your patient account.",
31
+ "AUTH/UNAUTHORIZED_ROLE",
32
+ 403
33
+ ),
29
34
 
30
35
  // Authentication errors
31
36
  NOT_AUTHENTICATED: new AuthError(
@@ -480,7 +480,9 @@ export class AuthService extends BaseService {
480
480
  // Check if user has clinic_admin role
481
481
  if (!user.roles?.includes(UserRole.CLINIC_ADMIN)) {
482
482
  console.error('[AUTH] User is not a clinic admin:', user.uid);
483
- throw AUTH_ERRORS.INVALID_ROLE;
483
+ // Sign out the user immediately for security
484
+ await this.auth.signOut();
485
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
484
486
  }
485
487
 
486
488
  // Check and get admin profile
@@ -314,7 +314,9 @@ export class AuthServiceV2 extends BaseService {
314
314
  // Check if user has clinic_admin role
315
315
  if (!user.roles?.includes(UserRole.CLINIC_ADMIN)) {
316
316
  console.error("[AUTH] User is not a clinic admin:", user.uid);
317
- throw AUTH_ERRORS.INVALID_ROLE;
317
+ // Sign out the user immediately for security
318
+ await this.auth.signOut();
319
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
318
320
  }
319
321
 
320
322
  // Check and get admin profile