mesauth-angular 0.1.7 → 0.1.8
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/README.md +44 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mes-auth.module.d.ts +2 -0
- package/dist/mes-auth.module.js +32 -0
- package/dist/user-profile.component.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,28 +11,37 @@ Angular helper library to connect to a backend API and SignalR hub to surface th
|
|
|
11
11
|
npm install ../path/to/mesauth-angular
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
2. Provide the service
|
|
15
|
-
- **For
|
|
14
|
+
2. Provide the service and import components:
|
|
15
|
+
- **For standalone components/apps**: Import `MesAuthModule` in your standalone component or `app.config.ts`.
|
|
16
16
|
```ts
|
|
17
|
-
import {
|
|
17
|
+
import { MesAuthModule } from 'mesauth-angular';
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
@Component({
|
|
20
|
+
standalone: true,
|
|
21
|
+
imports: [MesAuthModule, /* other imports */],
|
|
22
|
+
// ...
|
|
22
23
|
})
|
|
23
|
-
export class
|
|
24
|
+
export class MyComponent {}
|
|
24
25
|
```
|
|
25
|
-
|
|
26
|
+
Or in `app.config.ts`:
|
|
26
27
|
```ts
|
|
27
|
-
import {
|
|
28
|
+
import { MesAuthModule } from 'mesauth-angular';
|
|
28
29
|
|
|
29
30
|
export const appConfig: ApplicationConfig = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
MesAuthService
|
|
33
|
-
]
|
|
31
|
+
imports: [MesAuthModule],
|
|
32
|
+
// ... other config
|
|
34
33
|
};
|
|
35
34
|
```
|
|
35
|
+
- **For module-based apps**: Import `MesAuthModule` in your `AppModule` or feature module.
|
|
36
|
+
```ts
|
|
37
|
+
import { MesAuthModule } from 'mesauth-angular';
|
|
38
|
+
|
|
39
|
+
@NgModule({
|
|
40
|
+
imports: [MesAuthModule],
|
|
41
|
+
// ... other config
|
|
42
|
+
})
|
|
43
|
+
export class AppModule { }
|
|
44
|
+
```
|
|
36
45
|
|
|
37
46
|
3. (Optional) Provide the HTTP interceptor to handle 403 errors:
|
|
38
47
|
- The interceptor redirects to `${userBaseUrl}/403?returnUrl=encodedCurrentUrl` using `window.location.href` for external URLs (since `userBaseUrl` may be outside the client app).
|
|
@@ -146,6 +155,8 @@ Angular helper library to connect to a backend API and SignalR hub to surface th
|
|
|
146
155
|
|
|
147
156
|
## Components
|
|
148
157
|
|
|
158
|
+
**Note:** All components are standalone and can only be imported in standalone components or apps. If your app uses NgModules, use dynamic imports or convert to standalone.
|
|
159
|
+
|
|
149
160
|
### ma-user-profile
|
|
150
161
|
|
|
151
162
|
A reusable Angular component for displaying the current user's profile information, with options for navigation and logout.
|
|
@@ -232,3 +243,23 @@ If you encounter an error like "The injectable 'MesAuthService' needs to be comp
|
|
|
232
243
|
- If using standalone components, confirm the service is available in the injection context.
|
|
233
244
|
|
|
234
245
|
If issues persist, check your Angular version compatibility and ensure the package's `package.json` includes the correct entry points for AOT.
|
|
246
|
+
|
|
247
|
+
### Components Appear Empty
|
|
248
|
+
If components like `ma-user` or `ma-user-profile` render as empty:
|
|
249
|
+
- Ensure `MesAuthService` is provided in your app (see Quick Start step 2).
|
|
250
|
+
- Check browser console for logs from components (e.g., "UserProfileComponent: currentUser").
|
|
251
|
+
- If `currentUser` is null, the component shows a login button—verify the service is initialized and the API returns user data.
|
|
252
|
+
- For standalone apps, confirm `APP_INITIALIZER` or manual init is used.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
# Dynamic import in a module-based component
|
|
257
|
+
import { Component } from '@angular/core';
|
|
258
|
+
|
|
259
|
+
@Component({...})
|
|
260
|
+
export class DefaultHeaderComponent {
|
|
261
|
+
async ngOnInit() {
|
|
262
|
+
const { MaUserComponent } = await import('mesauth-angular');
|
|
263
|
+
// Use it dynamically
|
|
264
|
+
}
|
|
265
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { NgModule } from '@angular/core';
|
|
8
|
+
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
9
|
+
import { MesAuthService } from './mes-auth.service';
|
|
10
|
+
import { MesAuthInterceptor } from './mes-auth.interceptor';
|
|
11
|
+
import { UserProfileComponent } from './user-profile.component';
|
|
12
|
+
import { MaUserComponent } from './ma-user.component';
|
|
13
|
+
import { NotificationBadgeComponent } from './notification-badge.component';
|
|
14
|
+
import { NotificationPanelComponent } from './notification-panel.component';
|
|
15
|
+
// Import ToastContainerComponent if available
|
|
16
|
+
let MesAuthModule = class MesAuthModule {
|
|
17
|
+
};
|
|
18
|
+
MesAuthModule = __decorate([
|
|
19
|
+
NgModule({
|
|
20
|
+
providers: [
|
|
21
|
+
MesAuthService,
|
|
22
|
+
{ provide: HTTP_INTERCEPTORS, useClass: MesAuthInterceptor, multi: true }
|
|
23
|
+
],
|
|
24
|
+
exports: [
|
|
25
|
+
UserProfileComponent,
|
|
26
|
+
MaUserComponent,
|
|
27
|
+
NotificationBadgeComponent,
|
|
28
|
+
NotificationPanelComponent
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
], MesAuthModule);
|
|
32
|
+
export { MesAuthModule };
|
|
@@ -24,9 +24,11 @@ let UserProfileComponent = class UserProfileComponent {
|
|
|
24
24
|
this.destroy$ = new Subject();
|
|
25
25
|
}
|
|
26
26
|
ngOnInit() {
|
|
27
|
+
console.log('UserProfileComponent: Service injected?', !!this.authService);
|
|
27
28
|
this.authService.currentUser$
|
|
28
29
|
.pipe(takeUntil(this.destroy$))
|
|
29
30
|
.subscribe(user => {
|
|
31
|
+
console.log('UserProfileComponent: currentUser', user);
|
|
30
32
|
this.currentUser = user;
|
|
31
33
|
});
|
|
32
34
|
this.loadUnreadCount();
|