@blackcode_sa/metaestetics-api 1.14.2 → 1.14.3

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
@@ -16117,30 +16117,14 @@ var AuthService = class extends BaseService {
16117
16117
  404
16118
16118
  );
16119
16119
  }
16120
- console.log("[AUTH] Draft profiles found, attempting to create user document");
16120
+ console.log("[AUTH] Draft profiles found, returning to client for selection");
16121
16121
  const draftProfilesFound = await practitionerService2.getDraftProfilesByEmail(normalizedEmail);
16122
- try {
16123
- existingUser2 = await this.userService.createUser(firebaseUser2, ["practitioner" /* PRACTITIONER */], {
16124
- skipProfileCreation: true
16125
- });
16126
- console.log("[AUTH] Created user document for existing Firebase user with draft profiles:", existingUser2.uid);
16127
- } catch (createError) {
16128
- console.error("[AUTH] Error creating user document:", {
16129
- error: createError,
16130
- code: createError == null ? void 0 : createError.code,
16131
- message: createError == null ? void 0 : createError.message
16132
- });
16133
- try {
16134
- await (0, import_auth8.signOut)(this.auth);
16135
- } catch (signOutError) {
16136
- console.warn("[AUTH] Error signing out Firebase user (non-critical):", signOutError);
16137
- }
16138
- throw new AuthError(
16139
- "Unable to create account. Please use the token provided by your clinic to register, or contact support.",
16140
- "AUTH/USER_CREATION_FAILED",
16141
- 500
16142
- );
16143
- }
16122
+ return {
16123
+ user: null,
16124
+ // Will be created when claiming profiles
16125
+ practitioner: null,
16126
+ draftProfiles: draftProfilesFound
16127
+ };
16144
16128
  }
16145
16129
  if (!existingUser2) {
16146
16130
  await (0, import_auth8.signOut)(this.auth);
package/dist/index.mjs CHANGED
@@ -16204,30 +16204,14 @@ var AuthService = class extends BaseService {
16204
16204
  404
16205
16205
  );
16206
16206
  }
16207
- console.log("[AUTH] Draft profiles found, attempting to create user document");
16207
+ console.log("[AUTH] Draft profiles found, returning to client for selection");
16208
16208
  const draftProfilesFound = await practitionerService2.getDraftProfilesByEmail(normalizedEmail);
16209
- try {
16210
- existingUser2 = await this.userService.createUser(firebaseUser2, ["practitioner" /* PRACTITIONER */], {
16211
- skipProfileCreation: true
16212
- });
16213
- console.log("[AUTH] Created user document for existing Firebase user with draft profiles:", existingUser2.uid);
16214
- } catch (createError) {
16215
- console.error("[AUTH] Error creating user document:", {
16216
- error: createError,
16217
- code: createError == null ? void 0 : createError.code,
16218
- message: createError == null ? void 0 : createError.message
16219
- });
16220
- try {
16221
- await firebaseSignOut(this.auth);
16222
- } catch (signOutError) {
16223
- console.warn("[AUTH] Error signing out Firebase user (non-critical):", signOutError);
16224
- }
16225
- throw new AuthError(
16226
- "Unable to create account. Please use the token provided by your clinic to register, or contact support.",
16227
- "AUTH/USER_CREATION_FAILED",
16228
- 500
16229
- );
16230
- }
16209
+ return {
16210
+ user: null,
16211
+ // Will be created when claiming profiles
16212
+ practitioner: null,
16213
+ draftProfiles: draftProfilesFound
16214
+ };
16231
16215
  }
16232
16216
  if (!existingUser2) {
16233
16217
  await firebaseSignOut(this.auth);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.14.2",
4
+ "version": "1.14.3",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -1099,35 +1099,19 @@ export class AuthService extends BaseService {
1099
1099
  );
1100
1100
  }
1101
1101
 
1102
- // Draft profiles exist - try to create User document
1103
- // Firestore rules should allow authenticated users to create their own User document
1104
- console.log('[AUTH] Draft profiles found, attempting to create user document');
1102
+ // Draft profiles exist - return them to client
1103
+ // User document creation will happen server-side when claiming profiles
1104
+ // This avoids permission issues with client-side User document creation
1105
+ console.log('[AUTH] Draft profiles found, returning to client for selection');
1105
1106
  const draftProfilesFound = await practitionerService.getDraftProfilesByEmail(normalizedEmail);
1106
1107
 
1107
- try {
1108
- existingUser = await this.userService.createUser(firebaseUser, [UserRole.PRACTITIONER], {
1109
- skipProfileCreation: true,
1110
- });
1111
- console.log('[AUTH] Created user document for existing Firebase user with draft profiles:', existingUser.uid);
1112
- } catch (createError: any) {
1113
- console.error('[AUTH] Error creating user document:', {
1114
- error: createError,
1115
- code: createError?.code,
1116
- message: createError?.message,
1117
- });
1118
- // If creation fails, sign out and throw error
1119
- // User will need to use token flow or contact support
1120
- try {
1121
- await firebaseSignOut(this.auth);
1122
- } catch (signOutError) {
1123
- console.warn('[AUTH] Error signing out Firebase user (non-critical):', signOutError);
1124
- }
1125
- throw new AuthError(
1126
- 'Unable to create account. Please use the token provided by your clinic to register, or contact support.',
1127
- 'AUTH/USER_CREATION_FAILED',
1128
- 500,
1129
- );
1130
- }
1108
+ // Return draft profiles without creating User document
1109
+ // The User document will be created server-side via Cloud Function when claiming profiles
1110
+ return {
1111
+ user: null, // Will be created when claiming profiles
1112
+ practitioner: null,
1113
+ draftProfiles: draftProfilesFound,
1114
+ };
1131
1115
  }
1132
1116
 
1133
1117
  // User document exists - check for practitioner profile and draft profiles