@blackcode_sa/metaestetics-api 1.14.1 → 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.d.mts CHANGED
@@ -8443,7 +8443,7 @@ declare class AuthService extends BaseService {
8443
8443
  * @returns Object containing user, practitioner (if exists), and draft profiles (if any)
8444
8444
  */
8445
8445
  signUpPractitionerWithGoogle(idToken: string): Promise<{
8446
- user: User;
8446
+ user: User | null;
8447
8447
  practitioner: Practitioner | null;
8448
8448
  draftProfiles: Practitioner[];
8449
8449
  }>;
package/dist/index.d.ts CHANGED
@@ -8443,7 +8443,7 @@ declare class AuthService extends BaseService {
8443
8443
  * @returns Object containing user, practitioner (if exists), and draft profiles (if any)
8444
8444
  */
8445
8445
  signUpPractitionerWithGoogle(idToken: string): Promise<{
8446
- user: User;
8446
+ user: User | null;
8447
8447
  practitioner: Practitioner | null;
8448
8448
  draftProfiles: Practitioner[];
8449
8449
  }>;
package/dist/index.js CHANGED
@@ -16117,11 +16117,14 @@ var AuthService = class extends BaseService {
16117
16117
  404
16118
16118
  );
16119
16119
  }
16120
- console.log("[AUTH] Draft profiles found, creating user document");
16121
- existingUser2 = await this.userService.createUser(firebaseUser2, ["practitioner" /* PRACTITIONER */], {
16122
- skipProfileCreation: true
16123
- });
16124
- console.log("[AUTH] Created user document for existing Firebase user with draft profiles:", existingUser2.uid);
16120
+ console.log("[AUTH] Draft profiles found, returning to client for selection");
16121
+ const draftProfilesFound = await practitionerService2.getDraftProfilesByEmail(normalizedEmail);
16122
+ return {
16123
+ user: null,
16124
+ // Will be created when claiming profiles
16125
+ practitioner: null,
16126
+ draftProfiles: draftProfilesFound
16127
+ };
16125
16128
  }
16126
16129
  if (!existingUser2) {
16127
16130
  await (0, import_auth8.signOut)(this.auth);
package/dist/index.mjs CHANGED
@@ -16204,11 +16204,14 @@ var AuthService = class extends BaseService {
16204
16204
  404
16205
16205
  );
16206
16206
  }
16207
- console.log("[AUTH] Draft profiles found, creating user document");
16208
- existingUser2 = await this.userService.createUser(firebaseUser2, ["practitioner" /* PRACTITIONER */], {
16209
- skipProfileCreation: true
16210
- });
16211
- console.log("[AUTH] Created user document for existing Firebase user with draft profiles:", existingUser2.uid);
16207
+ console.log("[AUTH] Draft profiles found, returning to client for selection");
16208
+ const draftProfilesFound = await practitionerService2.getDraftProfilesByEmail(normalizedEmail);
16209
+ return {
16210
+ user: null,
16211
+ // Will be created when claiming profiles
16212
+ practitioner: null,
16213
+ draftProfiles: draftProfilesFound
16214
+ };
16212
16215
  }
16213
16216
  if (!existingUser2) {
16214
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.1",
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",
@@ -1012,7 +1012,7 @@ export class AuthService extends BaseService {
1012
1012
  async signUpPractitionerWithGoogle(
1013
1013
  idToken: string
1014
1014
  ): Promise<{
1015
- user: User;
1015
+ user: User | null;
1016
1016
  practitioner: Practitioner | null;
1017
1017
  draftProfiles: Practitioner[];
1018
1018
  }> {
@@ -1099,14 +1099,22 @@ export class AuthService extends BaseService {
1099
1099
  );
1100
1100
  }
1101
1101
 
1102
- // Draft profiles exist - create user document and continue
1103
- console.log('[AUTH] Draft profiles found, creating user document');
1104
- existingUser = await this.userService.createUser(firebaseUser, [UserRole.PRACTITIONER], {
1105
- skipProfileCreation: true,
1106
- });
1107
- console.log('[AUTH] Created user document for existing Firebase user with draft profiles:', existingUser.uid);
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');
1106
+ const draftProfilesFound = await practitionerService.getDraftProfilesByEmail(normalizedEmail);
1107
+
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
+ };
1108
1115
  }
1109
1116
 
1117
+ // User document exists - check for practitioner profile and draft profiles
1110
1118
  if (!existingUser) {
1111
1119
  await firebaseSignOut(this.auth);
1112
1120
  throw new AuthError(