@rolatech/angular-auth 19.1.0-beta.3 → 20.0.0-beta.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, signal, computed, Injectable, inject, output, model, PLATFORM_ID, LOCALE_ID, makeEnvironmentProviders } from '@angular/core';
2
+ import { Component, signal, computed, Injectable, inject, output, model, PLATFORM_ID, InjectionToken, makeEnvironmentProviders } from '@angular/core';
3
3
  import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule, MatDialog } from '@angular/material/dialog';
4
4
  import { APP_CONFIG, AngularCommonModule } from '@rolatech/angular-common';
5
5
  import { SnackBarService } from '@rolatech/angular-services';
@@ -320,18 +320,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
320
320
  }] });
321
321
 
322
322
  const AuthGuard = (route, state) => {
323
- const environment = inject(APP_CONFIG);
324
- const platformId = inject(PLATFORM_ID);
325
- const lang = inject(LOCALE_ID);
326
323
  const authService = inject(AuthService);
327
324
  const router = inject(Router);
325
+ const environment = inject(APP_CONFIG);
326
+ const platformId = inject(PLATFORM_ID);
328
327
  const isContinue = state.url.includes('continue');
329
328
  const continueUrl = route.queryParams['continue'];
329
+ // window = inject(WINDOW)
330
330
  if (!isPlatformBrowser(platformId)) {
331
331
  return of(false);
332
332
  }
333
333
  return authService.introspect().pipe(map$1(({ roles, authenticated }) => {
334
- console.log(lang);
335
334
  const routeRoles = route.data['roles'];
336
335
  const passRoled = routeRoles ? roles?.some((r) => routeRoles.indexOf(r) >= 0) : true;
337
336
  if (authenticated && !passRoled) {
@@ -349,13 +348,11 @@ const AuthGuard = (route, state) => {
349
348
  }
350
349
  else {
351
350
  if (!isContinue) {
352
- const decodedUrl = decodeURIComponent(window.location.href);
353
- window.location.href = environment.accountsUrl + `/signin?continue=${environment.myaccountUrl}`;
354
- // window.location.href = environment.accountsUrl + `/signin?continue=${window.location.href}`;
355
- // window.location.href = environment.accountsUrl + `/${lang}/signin?continue=${window.location.href}`;
351
+ window.location.href = environment.accountsUrl + `/signin?continue=${window.location.href}`;
356
352
  }
353
+ return true;
357
354
  }
358
- return true;
355
+ return authenticated;
359
356
  }));
360
357
  };
361
358
 
@@ -785,19 +782,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
785
782
  type: Injectable
786
783
  }], ctorParameters: () => [] });
787
784
 
788
- function provideAngularAuth() {
785
+ var AuthMethod;
786
+ (function (AuthMethod) {
787
+ AuthMethod["Password"] = "PASSWORD";
788
+ AuthMethod["OTP"] = "OTP";
789
+ AuthMethod["Google"] = "GOOGLE";
790
+ AuthMethod["WeChat"] = "WECHAT";
791
+ })(AuthMethod || (AuthMethod = {}));
792
+ const AUTH_METHODS = new InjectionToken('AUTH_METHODS');
793
+ function provideAngularAuth(config) {
789
794
  const providers = [
790
795
  { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
791
- // {
792
- // provide: ROUTES,
793
- // useValue: [
794
- // {
795
- // path: 'forbidden',
796
- // component: ForbiddenComponent,
797
- // },
798
- // ],
799
- // multi: true,
800
- // },
796
+ {
797
+ provide: AUTH_METHODS,
798
+ useValue: config?.methods,
799
+ },
801
800
  {
802
801
  provide: HTTP_INTERCEPTORS,
803
802
  useClass: AuthInterceptor,
@@ -822,5 +821,5 @@ const authRoutes = [
822
821
  * Generated bundle index. Do not edit.
823
822
  */
824
823
 
825
- export { AddressComponent, AddressType, AuthAgentService, AuthDialogGuard, AuthGuard, AuthInterceptor, AuthService, AuthStore, AuthUserService, ErrorInterceptor, FaceidDetectDialogComponent, ForbiddenComponent, LocalStorageService, PermissionGuard, RoleGuard, UnauthorizedComponent, UserStatus, authRoutes, provideAngularAuth };
824
+ export { AUTH_METHODS, AddressComponent, AddressType, AuthAgentService, AuthDialogGuard, AuthGuard, AuthInterceptor, AuthMethod, AuthService, AuthStore, AuthUserService, ErrorInterceptor, FaceidDetectDialogComponent, ForbiddenComponent, LocalStorageService, PermissionGuard, RoleGuard, UnauthorizedComponent, UserStatus, authRoutes, provideAngularAuth };
826
825
  //# sourceMappingURL=rolatech-angular-auth.mjs.map