@acorex/connectivity 20.6.0-next.8 → 20.6.0-next.9
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/api/index.d.ts
CHANGED
|
@@ -213,9 +213,6 @@ declare class AXMOidcTenantLoader implements AXPTenantLoader {
|
|
|
213
213
|
declare class AXCApiUserAvatarProvider implements AXPUserAvatarProvider {
|
|
214
214
|
private userService;
|
|
215
215
|
private sessionService;
|
|
216
|
-
private http;
|
|
217
|
-
private readonly configs;
|
|
218
|
-
private readonly baseUrl;
|
|
219
216
|
provide(userId: string): Promise<AXPUserAvatarData>;
|
|
220
217
|
}
|
|
221
218
|
|
|
@@ -796,43 +796,24 @@ class AXCApiUserAvatarProvider {
|
|
|
796
796
|
constructor() {
|
|
797
797
|
this.userService = inject(AXMUsersEntityService);
|
|
798
798
|
this.sessionService = inject(AXPSessionService);
|
|
799
|
-
this.http = inject(HttpClient);
|
|
800
|
-
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
|
801
|
-
this.baseUrl = this.configs.baseUrl;
|
|
802
799
|
}
|
|
803
800
|
async provide(userId) {
|
|
804
801
|
// Check if requesting current user info
|
|
805
802
|
const currentUser = this.sessionService.user;
|
|
806
803
|
const isCurrentUser = currentUser?.id === userId;
|
|
807
|
-
if (isCurrentUser) {
|
|
808
|
-
// Use
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
const userInfo = await firstValueFrom(this.http.get(userInfoUrl, { headers }));
|
|
820
|
-
const [firstName, lastName] = (userInfo.name || userInfo.sub || '').split(' ') || ['', ''];
|
|
821
|
-
return {
|
|
822
|
-
id: userInfo.sub || userId,
|
|
823
|
-
username: userInfo.preferred_username || userInfo.name || '',
|
|
824
|
-
firstName: firstName || userInfo.given_name || '',
|
|
825
|
-
lastName: lastName || userInfo.family_name || '',
|
|
826
|
-
status: 'online',
|
|
827
|
-
avatarUrl: userInfo.picture || 'https://via.placeholder.com/150',
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
catch (error) {
|
|
831
|
-
console.error('Failed to load userinfo from /connect/userinfo, falling back to entity service', error);
|
|
832
|
-
// Fallback to entity service if userinfo endpoint fails
|
|
833
|
-
}
|
|
804
|
+
if (isCurrentUser && currentUser) {
|
|
805
|
+
// Use session service user data for current user
|
|
806
|
+
const [firstName, lastName] = (currentUser.name || '').split(' ') || ['', ''];
|
|
807
|
+
return {
|
|
808
|
+
id: currentUser.id,
|
|
809
|
+
username: currentUser.name || '',
|
|
810
|
+
firstName: firstName || '',
|
|
811
|
+
lastName: lastName || '',
|
|
812
|
+
status: 'online',
|
|
813
|
+
avatarUrl: currentUser.avatar || `https://avatar.iran.liara.run/public/${AXPDataGenerator.pick([35, 22, 16, 6, 31])}`,
|
|
814
|
+
};
|
|
834
815
|
}
|
|
835
|
-
// Use entity service for other users
|
|
816
|
+
// Use entity service for other users
|
|
836
817
|
const user = await this.userService.getOne(userId);
|
|
837
818
|
if (!user) {
|
|
838
819
|
throw new Error(`User not found for ${userId}`);
|