@blackcode_sa/metaestetics-api 1.14.71 → 1.14.76
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 +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +68 -3
- package/dist/index.mjs +70 -4
- package/package.json +1 -1
- package/src/services/auth/auth.service.ts +84 -1
- package/src/services/user/user.service.ts +8 -2
package/dist/index.d.mts
CHANGED
|
@@ -8414,7 +8414,9 @@ declare class UserService extends BaseService {
|
|
|
8414
8414
|
/**
|
|
8415
8415
|
* Dohvata ili kreira korisnika na osnovu Firebase korisnika
|
|
8416
8416
|
*/
|
|
8417
|
-
getOrCreateUser(firebaseUser: User$1, initialRole?: UserRole
|
|
8417
|
+
getOrCreateUser(firebaseUser: User$1, initialRole?: UserRole, options?: {
|
|
8418
|
+
skipProfileCreation?: boolean;
|
|
8419
|
+
}): Promise<User>;
|
|
8418
8420
|
/**
|
|
8419
8421
|
* Kreira profile za odgovarajuće role
|
|
8420
8422
|
*/
|
|
@@ -8507,7 +8509,9 @@ declare class AuthService extends BaseService {
|
|
|
8507
8509
|
/**
|
|
8508
8510
|
* Prijavljuje korisnika anonimno
|
|
8509
8511
|
*/
|
|
8510
|
-
signInAnonymously(
|
|
8512
|
+
signInAnonymously(options?: {
|
|
8513
|
+
skipProfileCreation?: boolean;
|
|
8514
|
+
}): Promise<User>;
|
|
8511
8515
|
/**
|
|
8512
8516
|
* Odjavljuje trenutnog korisnika
|
|
8513
8517
|
*/
|
|
@@ -8615,6 +8619,22 @@ declare class AuthService extends BaseService {
|
|
|
8615
8619
|
* @returns The updated user profile.
|
|
8616
8620
|
*/
|
|
8617
8621
|
linkGoogleAccount(idToken: string): Promise<User>;
|
|
8622
|
+
/**
|
|
8623
|
+
* Sign in with Apple ID token (for existing users only).
|
|
8624
|
+
* Mirrors signInWithGoogleIdToken — verifies the user exists before allowing sign-in.
|
|
8625
|
+
*/
|
|
8626
|
+
signInWithAppleIdToken(idToken: string, rawNonce: string, appleUserInfo?: {
|
|
8627
|
+
fullName?: {
|
|
8628
|
+
givenName?: string;
|
|
8629
|
+
familyName?: string;
|
|
8630
|
+
};
|
|
8631
|
+
email?: string;
|
|
8632
|
+
}): Promise<User>;
|
|
8633
|
+
/**
|
|
8634
|
+
* Link an Apple account to the current user (anonymous → full account upgrade).
|
|
8635
|
+
* Mirrors linkGoogleAccount.
|
|
8636
|
+
*/
|
|
8637
|
+
linkAppleAccount(idToken: string, rawNonce: string): Promise<User>;
|
|
8618
8638
|
}
|
|
8619
8639
|
|
|
8620
8640
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -8414,7 +8414,9 @@ declare class UserService extends BaseService {
|
|
|
8414
8414
|
/**
|
|
8415
8415
|
* Dohvata ili kreira korisnika na osnovu Firebase korisnika
|
|
8416
8416
|
*/
|
|
8417
|
-
getOrCreateUser(firebaseUser: User$1, initialRole?: UserRole
|
|
8417
|
+
getOrCreateUser(firebaseUser: User$1, initialRole?: UserRole, options?: {
|
|
8418
|
+
skipProfileCreation?: boolean;
|
|
8419
|
+
}): Promise<User>;
|
|
8418
8420
|
/**
|
|
8419
8421
|
* Kreira profile za odgovarajuće role
|
|
8420
8422
|
*/
|
|
@@ -8507,7 +8509,9 @@ declare class AuthService extends BaseService {
|
|
|
8507
8509
|
/**
|
|
8508
8510
|
* Prijavljuje korisnika anonimno
|
|
8509
8511
|
*/
|
|
8510
|
-
signInAnonymously(
|
|
8512
|
+
signInAnonymously(options?: {
|
|
8513
|
+
skipProfileCreation?: boolean;
|
|
8514
|
+
}): Promise<User>;
|
|
8511
8515
|
/**
|
|
8512
8516
|
* Odjavljuje trenutnog korisnika
|
|
8513
8517
|
*/
|
|
@@ -8615,6 +8619,22 @@ declare class AuthService extends BaseService {
|
|
|
8615
8619
|
* @returns The updated user profile.
|
|
8616
8620
|
*/
|
|
8617
8621
|
linkGoogleAccount(idToken: string): Promise<User>;
|
|
8622
|
+
/**
|
|
8623
|
+
* Sign in with Apple ID token (for existing users only).
|
|
8624
|
+
* Mirrors signInWithGoogleIdToken — verifies the user exists before allowing sign-in.
|
|
8625
|
+
*/
|
|
8626
|
+
signInWithAppleIdToken(idToken: string, rawNonce: string, appleUserInfo?: {
|
|
8627
|
+
fullName?: {
|
|
8628
|
+
givenName?: string;
|
|
8629
|
+
familyName?: string;
|
|
8630
|
+
};
|
|
8631
|
+
email?: string;
|
|
8632
|
+
}): Promise<User>;
|
|
8633
|
+
/**
|
|
8634
|
+
* Link an Apple account to the current user (anonymous → full account upgrade).
|
|
8635
|
+
* Mirrors linkGoogleAccount.
|
|
8636
|
+
*/
|
|
8637
|
+
linkAppleAccount(idToken: string, rawNonce: string): Promise<User>;
|
|
8618
8638
|
}
|
|
8619
8639
|
|
|
8620
8640
|
/**
|
package/dist/index.js
CHANGED
|
@@ -13560,13 +13560,15 @@ var UserService = class extends BaseService {
|
|
|
13560
13560
|
/**
|
|
13561
13561
|
* Dohvata ili kreira korisnika na osnovu Firebase korisnika
|
|
13562
13562
|
*/
|
|
13563
|
-
async getOrCreateUser(firebaseUser, initialRole) {
|
|
13563
|
+
async getOrCreateUser(firebaseUser, initialRole, options) {
|
|
13564
13564
|
try {
|
|
13565
13565
|
const existingUser = await this.getUserById(firebaseUser.uid);
|
|
13566
13566
|
await this.updateUserLoginTimestamp(firebaseUser.uid);
|
|
13567
13567
|
return existingUser;
|
|
13568
13568
|
} catch (error) {
|
|
13569
|
-
return this.createUser(firebaseUser, [initialRole || "patient" /* PATIENT */]
|
|
13569
|
+
return this.createUser(firebaseUser, [initialRole || "patient" /* PATIENT */], {
|
|
13570
|
+
skipProfileCreation: options == null ? void 0 : options.skipProfileCreation
|
|
13571
|
+
});
|
|
13570
13572
|
}
|
|
13571
13573
|
}
|
|
13572
13574
|
/**
|
|
@@ -16381,8 +16383,11 @@ var AuthService = class extends BaseService {
|
|
|
16381
16383
|
/**
|
|
16382
16384
|
* Prijavljuje korisnika anonimno
|
|
16383
16385
|
*/
|
|
16384
|
-
async signInAnonymously() {
|
|
16386
|
+
async signInAnonymously(options) {
|
|
16385
16387
|
const { user: firebaseUser } = await (0, import_auth8.signInAnonymously)(this.auth);
|
|
16388
|
+
if (options == null ? void 0 : options.skipProfileCreation) {
|
|
16389
|
+
return this.userService.getOrCreateUser(firebaseUser, "patient" /* PATIENT */, { skipProfileCreation: true });
|
|
16390
|
+
}
|
|
16386
16391
|
return this.userService.getOrCreateUser(firebaseUser);
|
|
16387
16392
|
}
|
|
16388
16393
|
/**
|
|
@@ -17040,6 +17045,66 @@ var AuthService = class extends BaseService {
|
|
|
17040
17045
|
throw handleFirebaseError(error);
|
|
17041
17046
|
}
|
|
17042
17047
|
}
|
|
17048
|
+
/**
|
|
17049
|
+
* Sign in with Apple ID token (for existing users only).
|
|
17050
|
+
* Mirrors signInWithGoogleIdToken — verifies the user exists before allowing sign-in.
|
|
17051
|
+
*/
|
|
17052
|
+
async signInWithAppleIdToken(idToken, rawNonce, appleUserInfo) {
|
|
17053
|
+
try {
|
|
17054
|
+
console.log("[AUTH] Signing in with Apple ID Token");
|
|
17055
|
+
const provider = new import_auth8.OAuthProvider("apple.com");
|
|
17056
|
+
const credential = provider.credential({ idToken, rawNonce });
|
|
17057
|
+
const { user: firebaseUser } = await (0, import_auth8.signInWithCredential)(this.auth, credential);
|
|
17058
|
+
console.log("[AUTH] Firebase user signed in via Apple:", firebaseUser.uid);
|
|
17059
|
+
const existingUser = await this.userService.getUserById(firebaseUser.uid);
|
|
17060
|
+
if (existingUser) {
|
|
17061
|
+
console.log("[AUTH] Existing user found, returning profile:", existingUser.uid);
|
|
17062
|
+
return existingUser;
|
|
17063
|
+
}
|
|
17064
|
+
console.log("[AUTH] No existing MetaEstetics user for Apple account \u2013 signing out.");
|
|
17065
|
+
await (0, import_auth8.signOut)(this.auth);
|
|
17066
|
+
throw new AuthError(
|
|
17067
|
+
'No account found. Please complete registration by starting with "Get Started".',
|
|
17068
|
+
"AUTH/USER_NOT_FOUND",
|
|
17069
|
+
404
|
|
17070
|
+
);
|
|
17071
|
+
} catch (error) {
|
|
17072
|
+
console.error("[AUTH] Error in signInWithAppleIdToken:", error);
|
|
17073
|
+
throw handleFirebaseError(error);
|
|
17074
|
+
}
|
|
17075
|
+
}
|
|
17076
|
+
/**
|
|
17077
|
+
* Link an Apple account to the current user (anonymous → full account upgrade).
|
|
17078
|
+
* Mirrors linkGoogleAccount.
|
|
17079
|
+
*/
|
|
17080
|
+
async linkAppleAccount(idToken, rawNonce) {
|
|
17081
|
+
try {
|
|
17082
|
+
console.log("[AUTH] Linking Apple account with ID Token");
|
|
17083
|
+
const currentUser = this.auth.currentUser;
|
|
17084
|
+
if (!currentUser) {
|
|
17085
|
+
throw AUTH_ERRORS.NOT_AUTHENTICATED;
|
|
17086
|
+
}
|
|
17087
|
+
const wasAnonymous = currentUser.isAnonymous;
|
|
17088
|
+
console.log(`[AUTH] Current user is ${wasAnonymous ? "anonymous" : "not anonymous"}`);
|
|
17089
|
+
const provider = new import_auth8.OAuthProvider("apple.com");
|
|
17090
|
+
const credential = provider.credential({ idToken, rawNonce });
|
|
17091
|
+
const userCredential = await (0, import_auth8.linkWithCredential)(currentUser, credential);
|
|
17092
|
+
const linkedFirebaseUser = userCredential.user;
|
|
17093
|
+
console.log("[AUTH] Apple account linked successfully to user:", linkedFirebaseUser.uid);
|
|
17094
|
+
if (wasAnonymous) {
|
|
17095
|
+
console.log("[AUTH] Upgrading anonymous user profile");
|
|
17096
|
+
const email = linkedFirebaseUser.email || "";
|
|
17097
|
+
return await this.userService.upgradeAnonymousUser(
|
|
17098
|
+
linkedFirebaseUser.uid,
|
|
17099
|
+
email
|
|
17100
|
+
);
|
|
17101
|
+
}
|
|
17102
|
+
return await this.userService.getUserById(linkedFirebaseUser.uid);
|
|
17103
|
+
} catch (error) {
|
|
17104
|
+
console.error("[AUTH] Error in linkAppleAccount:", error);
|
|
17105
|
+
throw handleFirebaseError(error);
|
|
17106
|
+
}
|
|
17107
|
+
}
|
|
17043
17108
|
};
|
|
17044
17109
|
|
|
17045
17110
|
// src/services/calendar/calendar.v2.service.ts
|
package/dist/index.mjs
CHANGED
|
@@ -7639,7 +7639,8 @@ import {
|
|
|
7639
7639
|
verifyPasswordResetCode,
|
|
7640
7640
|
confirmPasswordReset,
|
|
7641
7641
|
fetchSignInMethodsForEmail as fetchSignInMethodsForEmail2,
|
|
7642
|
-
signInWithCredential
|
|
7642
|
+
signInWithCredential,
|
|
7643
|
+
OAuthProvider
|
|
7643
7644
|
} from "firebase/auth";
|
|
7644
7645
|
import {
|
|
7645
7646
|
collection as collection21,
|
|
@@ -13584,13 +13585,15 @@ var UserService = class extends BaseService {
|
|
|
13584
13585
|
/**
|
|
13585
13586
|
* Dohvata ili kreira korisnika na osnovu Firebase korisnika
|
|
13586
13587
|
*/
|
|
13587
|
-
async getOrCreateUser(firebaseUser, initialRole) {
|
|
13588
|
+
async getOrCreateUser(firebaseUser, initialRole, options) {
|
|
13588
13589
|
try {
|
|
13589
13590
|
const existingUser = await this.getUserById(firebaseUser.uid);
|
|
13590
13591
|
await this.updateUserLoginTimestamp(firebaseUser.uid);
|
|
13591
13592
|
return existingUser;
|
|
13592
13593
|
} catch (error) {
|
|
13593
|
-
return this.createUser(firebaseUser, [initialRole || "patient" /* PATIENT */]
|
|
13594
|
+
return this.createUser(firebaseUser, [initialRole || "patient" /* PATIENT */], {
|
|
13595
|
+
skipProfileCreation: options == null ? void 0 : options.skipProfileCreation
|
|
13596
|
+
});
|
|
13594
13597
|
}
|
|
13595
13598
|
}
|
|
13596
13599
|
/**
|
|
@@ -16469,8 +16472,11 @@ var AuthService = class extends BaseService {
|
|
|
16469
16472
|
/**
|
|
16470
16473
|
* Prijavljuje korisnika anonimno
|
|
16471
16474
|
*/
|
|
16472
|
-
async signInAnonymously() {
|
|
16475
|
+
async signInAnonymously(options) {
|
|
16473
16476
|
const { user: firebaseUser } = await firebaseSignInAnonymously(this.auth);
|
|
16477
|
+
if (options == null ? void 0 : options.skipProfileCreation) {
|
|
16478
|
+
return this.userService.getOrCreateUser(firebaseUser, "patient" /* PATIENT */, { skipProfileCreation: true });
|
|
16479
|
+
}
|
|
16474
16480
|
return this.userService.getOrCreateUser(firebaseUser);
|
|
16475
16481
|
}
|
|
16476
16482
|
/**
|
|
@@ -17128,6 +17134,66 @@ var AuthService = class extends BaseService {
|
|
|
17128
17134
|
throw handleFirebaseError(error);
|
|
17129
17135
|
}
|
|
17130
17136
|
}
|
|
17137
|
+
/**
|
|
17138
|
+
* Sign in with Apple ID token (for existing users only).
|
|
17139
|
+
* Mirrors signInWithGoogleIdToken — verifies the user exists before allowing sign-in.
|
|
17140
|
+
*/
|
|
17141
|
+
async signInWithAppleIdToken(idToken, rawNonce, appleUserInfo) {
|
|
17142
|
+
try {
|
|
17143
|
+
console.log("[AUTH] Signing in with Apple ID Token");
|
|
17144
|
+
const provider = new OAuthProvider("apple.com");
|
|
17145
|
+
const credential = provider.credential({ idToken, rawNonce });
|
|
17146
|
+
const { user: firebaseUser } = await signInWithCredential(this.auth, credential);
|
|
17147
|
+
console.log("[AUTH] Firebase user signed in via Apple:", firebaseUser.uid);
|
|
17148
|
+
const existingUser = await this.userService.getUserById(firebaseUser.uid);
|
|
17149
|
+
if (existingUser) {
|
|
17150
|
+
console.log("[AUTH] Existing user found, returning profile:", existingUser.uid);
|
|
17151
|
+
return existingUser;
|
|
17152
|
+
}
|
|
17153
|
+
console.log("[AUTH] No existing MetaEstetics user for Apple account \u2013 signing out.");
|
|
17154
|
+
await firebaseSignOut(this.auth);
|
|
17155
|
+
throw new AuthError(
|
|
17156
|
+
'No account found. Please complete registration by starting with "Get Started".',
|
|
17157
|
+
"AUTH/USER_NOT_FOUND",
|
|
17158
|
+
404
|
|
17159
|
+
);
|
|
17160
|
+
} catch (error) {
|
|
17161
|
+
console.error("[AUTH] Error in signInWithAppleIdToken:", error);
|
|
17162
|
+
throw handleFirebaseError(error);
|
|
17163
|
+
}
|
|
17164
|
+
}
|
|
17165
|
+
/**
|
|
17166
|
+
* Link an Apple account to the current user (anonymous → full account upgrade).
|
|
17167
|
+
* Mirrors linkGoogleAccount.
|
|
17168
|
+
*/
|
|
17169
|
+
async linkAppleAccount(idToken, rawNonce) {
|
|
17170
|
+
try {
|
|
17171
|
+
console.log("[AUTH] Linking Apple account with ID Token");
|
|
17172
|
+
const currentUser = this.auth.currentUser;
|
|
17173
|
+
if (!currentUser) {
|
|
17174
|
+
throw AUTH_ERRORS.NOT_AUTHENTICATED;
|
|
17175
|
+
}
|
|
17176
|
+
const wasAnonymous = currentUser.isAnonymous;
|
|
17177
|
+
console.log(`[AUTH] Current user is ${wasAnonymous ? "anonymous" : "not anonymous"}`);
|
|
17178
|
+
const provider = new OAuthProvider("apple.com");
|
|
17179
|
+
const credential = provider.credential({ idToken, rawNonce });
|
|
17180
|
+
const userCredential = await linkWithCredential(currentUser, credential);
|
|
17181
|
+
const linkedFirebaseUser = userCredential.user;
|
|
17182
|
+
console.log("[AUTH] Apple account linked successfully to user:", linkedFirebaseUser.uid);
|
|
17183
|
+
if (wasAnonymous) {
|
|
17184
|
+
console.log("[AUTH] Upgrading anonymous user profile");
|
|
17185
|
+
const email = linkedFirebaseUser.email || "";
|
|
17186
|
+
return await this.userService.upgradeAnonymousUser(
|
|
17187
|
+
linkedFirebaseUser.uid,
|
|
17188
|
+
email
|
|
17189
|
+
);
|
|
17190
|
+
}
|
|
17191
|
+
return await this.userService.getUserById(linkedFirebaseUser.uid);
|
|
17192
|
+
} catch (error) {
|
|
17193
|
+
console.error("[AUTH] Error in linkAppleAccount:", error);
|
|
17194
|
+
throw handleFirebaseError(error);
|
|
17195
|
+
}
|
|
17196
|
+
}
|
|
17131
17197
|
};
|
|
17132
17198
|
|
|
17133
17199
|
// src/services/calendar/calendar.v2.service.ts
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
confirmPasswordReset,
|
|
18
18
|
fetchSignInMethodsForEmail,
|
|
19
19
|
signInWithCredential,
|
|
20
|
+
OAuthProvider,
|
|
20
21
|
} from 'firebase/auth';
|
|
21
22
|
import {
|
|
22
23
|
getFirestore,
|
|
@@ -562,9 +563,13 @@ export class AuthService extends BaseService {
|
|
|
562
563
|
/**
|
|
563
564
|
* Prijavljuje korisnika anonimno
|
|
564
565
|
*/
|
|
565
|
-
async signInAnonymously(): Promise<User> {
|
|
566
|
+
async signInAnonymously(options?: { skipProfileCreation?: boolean }): Promise<User> {
|
|
566
567
|
const { user: firebaseUser } = await firebaseSignInAnonymously(this.auth);
|
|
567
568
|
|
|
569
|
+
if (options?.skipProfileCreation) {
|
|
570
|
+
return this.userService.getOrCreateUser(firebaseUser, UserRole.PATIENT, { skipProfileCreation: true });
|
|
571
|
+
}
|
|
572
|
+
|
|
568
573
|
return this.userService.getOrCreateUser(firebaseUser);
|
|
569
574
|
}
|
|
570
575
|
|
|
@@ -1411,4 +1416,82 @@ export class AuthService extends BaseService {
|
|
|
1411
1416
|
throw handleFirebaseError(error);
|
|
1412
1417
|
}
|
|
1413
1418
|
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Sign in with Apple ID token (for existing users only).
|
|
1422
|
+
* Mirrors signInWithGoogleIdToken — verifies the user exists before allowing sign-in.
|
|
1423
|
+
*/
|
|
1424
|
+
async signInWithAppleIdToken(
|
|
1425
|
+
idToken: string,
|
|
1426
|
+
rawNonce: string,
|
|
1427
|
+
appleUserInfo?: { fullName?: { givenName?: string; familyName?: string }; email?: string },
|
|
1428
|
+
): Promise<User> {
|
|
1429
|
+
try {
|
|
1430
|
+
console.log('[AUTH] Signing in with Apple ID Token');
|
|
1431
|
+
|
|
1432
|
+
// Build Apple OAuth credential
|
|
1433
|
+
const provider = new OAuthProvider('apple.com');
|
|
1434
|
+
const credential = provider.credential({ idToken, rawNonce });
|
|
1435
|
+
|
|
1436
|
+
// Sign in to Firebase
|
|
1437
|
+
const { user: firebaseUser } = await signInWithCredential(this.auth, credential);
|
|
1438
|
+
console.log('[AUTH] Firebase user signed in via Apple:', firebaseUser.uid);
|
|
1439
|
+
|
|
1440
|
+
// Load domain user document
|
|
1441
|
+
const existingUser = await this.userService.getUserById(firebaseUser.uid);
|
|
1442
|
+
if (existingUser) {
|
|
1443
|
+
console.log('[AUTH] Existing user found, returning profile:', existingUser.uid);
|
|
1444
|
+
return existingUser;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// No user document — sign out and error
|
|
1448
|
+
console.log('[AUTH] No existing MetaEstetics user for Apple account – signing out.');
|
|
1449
|
+
await firebaseSignOut(this.auth);
|
|
1450
|
+
throw new AuthError(
|
|
1451
|
+
'No account found. Please complete registration by starting with "Get Started".',
|
|
1452
|
+
'AUTH/USER_NOT_FOUND',
|
|
1453
|
+
404,
|
|
1454
|
+
);
|
|
1455
|
+
} catch (error) {
|
|
1456
|
+
console.error('[AUTH] Error in signInWithAppleIdToken:', error);
|
|
1457
|
+
throw handleFirebaseError(error);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Link an Apple account to the current user (anonymous → full account upgrade).
|
|
1463
|
+
* Mirrors linkGoogleAccount.
|
|
1464
|
+
*/
|
|
1465
|
+
async linkAppleAccount(idToken: string, rawNonce: string): Promise<User> {
|
|
1466
|
+
try {
|
|
1467
|
+
console.log('[AUTH] Linking Apple account with ID Token');
|
|
1468
|
+
const currentUser = this.auth.currentUser;
|
|
1469
|
+
if (!currentUser) {
|
|
1470
|
+
throw AUTH_ERRORS.NOT_AUTHENTICATED;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
const wasAnonymous = currentUser.isAnonymous;
|
|
1474
|
+
console.log(`[AUTH] Current user is ${wasAnonymous ? 'anonymous' : 'not anonymous'}`);
|
|
1475
|
+
|
|
1476
|
+
const provider = new OAuthProvider('apple.com');
|
|
1477
|
+
const credential = provider.credential({ idToken, rawNonce });
|
|
1478
|
+
const userCredential = await linkWithCredential(currentUser, credential);
|
|
1479
|
+
const linkedFirebaseUser = userCredential.user;
|
|
1480
|
+
console.log('[AUTH] Apple account linked successfully to user:', linkedFirebaseUser.uid);
|
|
1481
|
+
|
|
1482
|
+
if (wasAnonymous) {
|
|
1483
|
+
console.log('[AUTH] Upgrading anonymous user profile');
|
|
1484
|
+
const email = linkedFirebaseUser.email || '';
|
|
1485
|
+
return await this.userService.upgradeAnonymousUser(
|
|
1486
|
+
linkedFirebaseUser.uid,
|
|
1487
|
+
email,
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
return (await this.userService.getUserById(linkedFirebaseUser.uid))!;
|
|
1492
|
+
} catch (error) {
|
|
1493
|
+
console.error('[AUTH] Error in linkAppleAccount:', error);
|
|
1494
|
+
throw handleFirebaseError(error);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1414
1497
|
}
|
|
@@ -116,13 +116,19 @@ export class UserService extends BaseService {
|
|
|
116
116
|
/**
|
|
117
117
|
* Dohvata ili kreira korisnika na osnovu Firebase korisnika
|
|
118
118
|
*/
|
|
119
|
-
async getOrCreateUser(
|
|
119
|
+
async getOrCreateUser(
|
|
120
|
+
firebaseUser: FirebaseUser,
|
|
121
|
+
initialRole?: UserRole,
|
|
122
|
+
options?: { skipProfileCreation?: boolean },
|
|
123
|
+
): Promise<User> {
|
|
120
124
|
try {
|
|
121
125
|
const existingUser = await this.getUserById(firebaseUser.uid);
|
|
122
126
|
await this.updateUserLoginTimestamp(firebaseUser.uid);
|
|
123
127
|
return existingUser;
|
|
124
128
|
} catch (error) {
|
|
125
|
-
return this.createUser(firebaseUser, [initialRole || UserRole.PATIENT]
|
|
129
|
+
return this.createUser(firebaseUser, [initialRole || UserRole.PATIENT], {
|
|
130
|
+
skipProfileCreation: options?.skipProfileCreation,
|
|
131
|
+
});
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
|