mesauth-angular 0.1.9 → 0.1.10
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.
|
@@ -21,7 +21,7 @@ let MesAuthInterceptor = class MesAuthInterceptor {
|
|
|
21
21
|
return next.handle(req).pipe(catchError((error) => {
|
|
22
22
|
if (error.status === 403) {
|
|
23
23
|
const config = this.authService.getConfig();
|
|
24
|
-
const baseUrl =
|
|
24
|
+
const baseUrl = config?.userBaseUrl || '';
|
|
25
25
|
const returnUrl = encodeURIComponent(window.location.href);
|
|
26
26
|
window.location.href = `${baseUrl}/403?returnUrl=${returnUrl}`;
|
|
27
27
|
}
|
package/dist/mes-auth.service.js
CHANGED
|
@@ -50,7 +50,7 @@ let MesAuthService = class MesAuthService {
|
|
|
50
50
|
return;
|
|
51
51
|
this.http.get(`${this.apiBase}/notif/me`).subscribe({
|
|
52
52
|
next: (notifications) => {
|
|
53
|
-
if (Array.isArray(notifications
|
|
53
|
+
if (Array.isArray(notifications?.items)) {
|
|
54
54
|
notifications.items.forEach((n) => this._notifications.next(n));
|
|
55
55
|
}
|
|
56
56
|
},
|
|
@@ -77,12 +77,11 @@ let MesAuthService = class MesAuthService {
|
|
|
77
77
|
return this.http.delete(`${this.apiBase}/notif/${notificationId}`);
|
|
78
78
|
}
|
|
79
79
|
startConnection(config) {
|
|
80
|
-
var _a;
|
|
81
80
|
if (this.hubConnection)
|
|
82
81
|
return;
|
|
83
82
|
const signalrUrl = config.apiBaseUrl.replace(/\/$/, '') + '/hub/notification';
|
|
84
83
|
const builder = new HubConnectionBuilder()
|
|
85
|
-
.withUrl(signalrUrl, { withCredentials:
|
|
84
|
+
.withUrl(signalrUrl, { withCredentials: config.withCredentials ?? true })
|
|
86
85
|
.withAutomaticReconnect()
|
|
87
86
|
.configureLogging(LogLevel.Warning);
|
|
88
87
|
this.hubConnection = builder.build();
|
|
@@ -53,7 +53,7 @@ let UserProfileComponent = class UserProfileComponent {
|
|
|
53
53
|
}
|
|
54
54
|
getAvatarUrl(user) {
|
|
55
55
|
const config = this.authService.getConfig();
|
|
56
|
-
const baseUrl =
|
|
56
|
+
const baseUrl = config?.avatarUrl || 'https://ui-avatars.com/api/';
|
|
57
57
|
// Use userName first, fallback to userId, final fallback to 'User'
|
|
58
58
|
const displayName = user.userName || user.userId || 'User';
|
|
59
59
|
return `${baseUrl}?name=${encodeURIComponent(displayName)}&background=1976d2&color=fff`;
|
|
@@ -69,13 +69,13 @@ let UserProfileComponent = class UserProfileComponent {
|
|
|
69
69
|
}
|
|
70
70
|
onLogin() {
|
|
71
71
|
const config = this.authService.getConfig();
|
|
72
|
-
const baseUrl =
|
|
72
|
+
const baseUrl = config?.userBaseUrl || '';
|
|
73
73
|
const returnUrl = encodeURIComponent(this.router.url);
|
|
74
74
|
window.location.href = `${baseUrl}/login?returnUrl=${returnUrl}`;
|
|
75
75
|
}
|
|
76
76
|
onViewProfile() {
|
|
77
77
|
const config = this.authService.getConfig();
|
|
78
|
-
const baseUrl =
|
|
78
|
+
const baseUrl = config?.userBaseUrl || '';
|
|
79
79
|
window.location.href = `${baseUrl}/profile`;
|
|
80
80
|
this.dropdownOpen = false;
|
|
81
81
|
}
|
|
@@ -87,7 +87,7 @@ let UserProfileComponent = class UserProfileComponent {
|
|
|
87
87
|
this.dropdownOpen = false;
|
|
88
88
|
// Navigate to login with return URL
|
|
89
89
|
const config = this.authService.getConfig();
|
|
90
|
-
const baseUrl =
|
|
90
|
+
const baseUrl = config?.userBaseUrl || '';
|
|
91
91
|
const returnUrl = encodeURIComponent(window.location.href);
|
|
92
92
|
window.location.href = `${baseUrl}/login?returnUrl=${returnUrl}`;
|
|
93
93
|
},
|
|
@@ -95,7 +95,7 @@ let UserProfileComponent = class UserProfileComponent {
|
|
|
95
95
|
console.error('Logout error:', err);
|
|
96
96
|
// Still navigate to login even if logout fails
|
|
97
97
|
const config = this.authService.getConfig();
|
|
98
|
-
const baseUrl =
|
|
98
|
+
const baseUrl = config?.userBaseUrl || '';
|
|
99
99
|
window.location.href = `${baseUrl}/login`;
|
|
100
100
|
}
|
|
101
101
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mesauth-angular",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Angular
|
|
3
|
+
"version": "0.1.10",
|
|
4
|
+
"description": "Angular helper library to connect to a backend API and SignalR hub to surface the current logged-in user and incoming notifications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": ["dist"],
|