@blackcode_sa/metaestetics-api 1.14.1 → 1.14.2
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -5
- package/dist/index.mjs +24 -5
- package/package.json +1 -1
- package/src/services/auth/auth.service.ts +31 -7
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,30 @@ var AuthService = class extends BaseService {
|
|
|
16117
16117
|
404
|
|
16118
16118
|
);
|
|
16119
16119
|
}
|
|
16120
|
-
console.log("[AUTH] Draft profiles found,
|
|
16121
|
-
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16120
|
+
console.log("[AUTH] Draft profiles found, attempting to create user document");
|
|
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
|
+
}
|
|
16125
16144
|
}
|
|
16126
16145
|
if (!existingUser2) {
|
|
16127
16146
|
await (0, import_auth8.signOut)(this.auth);
|
package/dist/index.mjs
CHANGED
|
@@ -16204,11 +16204,30 @@ var AuthService = class extends BaseService {
|
|
|
16204
16204
|
404
|
|
16205
16205
|
);
|
|
16206
16206
|
}
|
|
16207
|
-
console.log("[AUTH] Draft profiles found,
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16207
|
+
console.log("[AUTH] Draft profiles found, attempting to create user document");
|
|
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
|
+
}
|
|
16212
16231
|
}
|
|
16213
16232
|
if (!existingUser2) {
|
|
16214
16233
|
await firebaseSignOut(this.auth);
|
package/package.json
CHANGED
|
@@ -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,38 @@ export class AuthService extends BaseService {
|
|
|
1099
1099
|
);
|
|
1100
1100
|
}
|
|
1101
1101
|
|
|
1102
|
-
// Draft profiles exist - create
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
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');
|
|
1105
|
+
const draftProfilesFound = await practitionerService.getDraftProfilesByEmail(normalizedEmail);
|
|
1106
|
+
|
|
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
1131
|
}
|
|
1109
1132
|
|
|
1133
|
+
// User document exists - check for practitioner profile and draft profiles
|
|
1110
1134
|
if (!existingUser) {
|
|
1111
1135
|
await firebaseSignOut(this.auth);
|
|
1112
1136
|
throw new AuthError(
|