sync build tree from private myoffice
This commit is contained in:
@@ -9,7 +9,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
|||||||
import { LoadingBarRouterModule } from '@ngx-loading-bar/router';
|
import { LoadingBarRouterModule } from '@ngx-loading-bar/router';
|
||||||
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';
|
import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';
|
||||||
import { NgScrollbarModule } from 'ngx-scrollbar';
|
import { NgScrollbarModule } from 'ngx-scrollbar';
|
||||||
import { SocialAuthService, SocialLoginModule } from '@abacritt/angularx-social-login';
|
import { SocialLoginModule } from '@abacritt/angularx-social-login';
|
||||||
|
|
||||||
// app
|
// app
|
||||||
import { CoreModule } from './core/core.module';
|
import { CoreModule } from './core/core.module';
|
||||||
@@ -17,13 +17,31 @@ import { AppRoutingModule } from './app-routing.module';
|
|||||||
import { ErrorInterceptor } from './core/interceptor/error.interceptor';
|
import { ErrorInterceptor } from './core/interceptor/error.interceptor';
|
||||||
import { UpdateDateHttpInterceptor } from './core/interceptor/update.date.http.interceptor ';
|
import { UpdateDateHttpInterceptor } from './core/interceptor/update.date.http.interceptor ';
|
||||||
import { ExternalLoginConfig } from './config.external-login';
|
import { ExternalLoginConfig } from './config.external-login';
|
||||||
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
export function createTranslateLoader(http: HttpClient) {
|
export function createTranslateLoader(http: HttpClient) {
|
||||||
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
|
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const socialProviders = environment.externalLogins?.google?.clientId
|
||||||
|
? [
|
||||||
|
importProvidersFrom(SocialLoginModule.initialize(ExternalLoginConfig.getSocialConfig())),
|
||||||
|
{
|
||||||
|
provide: 'SocialAuthServiceConfig',
|
||||||
|
useValue: ExternalLoginConfig.getSocialConfig(),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
// Empty config so providedIn:'root' SocialAuthService (if ever constructed) does not crash.
|
||||||
|
{
|
||||||
|
provide: 'SocialAuthServiceConfig',
|
||||||
|
useValue: ExternalLoginConfig.getSocialConfig(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
|
...socialProviders,
|
||||||
importProvidersFrom(
|
importProvidersFrom(
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
@@ -38,14 +56,7 @@ export const appConfig: ApplicationConfig = {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
CoreModule,
|
CoreModule,
|
||||||
SocialLoginModule,
|
|
||||||
),
|
),
|
||||||
// AuthService is providedIn: 'root' — config must be on the app injector (string token for lib 2.1.x)
|
|
||||||
{
|
|
||||||
provide: 'SocialAuthServiceConfig',
|
|
||||||
useValue: ExternalLoginConfig.getSocialConfig(),
|
|
||||||
},
|
|
||||||
SocialAuthService,
|
|
||||||
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
|
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: UpdateDateHttpInterceptor, multi: true },
|
{ provide: HTTP_INTERCEPTORS, useClass: UpdateDateHttpInterceptor, multi: true },
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ import { SigninComponent } from './signin/signin.component';
|
|||||||
import { SignupComponent } from './signup/signup.component';
|
import { SignupComponent } from './signup/signup.component';
|
||||||
import { LockedComponent } from './locked/locked.component';
|
import { LockedComponent } from './locked/locked.component';
|
||||||
import { ForgotPasswordComponent } from './forgot-password/forgot-password.component';
|
import { ForgotPasswordComponent } from './forgot-password/forgot-password.component';
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
|
const googleButtonImports = environment.externalLogins?.google?.clientId
|
||||||
|
? [GoogleSigninButtonModule]
|
||||||
|
: [];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -30,7 +35,7 @@ import { ForgotPasswordComponent } from './forgot-password/forgot-password.compo
|
|||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
GoogleSigninButtonModule,
|
...googleButtonImports,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
Page500Component,
|
Page500Component,
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { Router, ActivatedRoute } from '@angular/router';
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
// libs
|
|
||||||
import { SocialAuthService } from '@abacritt/angularx-social-login';
|
|
||||||
|
|
||||||
// app
|
// app
|
||||||
import { AuthService } from 'src/app/core/service/auth.service';
|
import { AuthService } from 'src/app/core/service/auth.service';
|
||||||
import { UnsubscribeOnDestroyAdapter } from 'src/app/shared/UnsubscribeOnDestroyAdapter';
|
import { UnsubscribeOnDestroyAdapter } from 'src/app/shared/UnsubscribeOnDestroyAdapter';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// angular
|
// angular
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable, Injector } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
@@ -28,6 +28,7 @@ import { UserProfileModel } from '../models/user-profile.model';
|
|||||||
import { GeneralResultModel } from '../models/general-result.model';
|
import { GeneralResultModel } from '../models/general-result.model';
|
||||||
import { getSafeRedirectUrl } from '../utils/safe-redirect';
|
import { getSafeRedirectUrl } from '../utils/safe-redirect';
|
||||||
import { SubjectExtensions } from '../extensions/general.extensions';
|
import { SubjectExtensions } from '../extensions/general.extensions';
|
||||||
|
import { environment } from '../../../environments/environment';
|
||||||
|
|
||||||
export function authAppInitializerFactory(authService: AuthService): () => Promise<void> {
|
export function authAppInitializerFactory(authService: AuthService): () => Promise<void> {
|
||||||
if (window.location.href.indexOf('/silent-refresh.html') !== -1) {
|
if (window.location.href.indexOf('/silent-refresh.html') !== -1) {
|
||||||
@@ -52,17 +53,21 @@ export class AuthService {
|
|||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private oidcHelperService: OidcHelperService,
|
private oidcHelperService: OidcHelperService,
|
||||||
private auth0Service: Auth0Service,
|
private auth0Service: Auth0Service,
|
||||||
private externalAuthService: SocialAuthService,
|
private injector: Injector,
|
||||||
) {
|
) {
|
||||||
this.currentUserSubject = new BehaviorSubject<UserModel>({} as UserModel);
|
this.currentUserSubject = new BehaviorSubject<UserModel>({} as UserModel);
|
||||||
this.currentUser$ = this.currentUserSubject.asObservable();
|
this.currentUser$ = this.currentUserSubject.asObservable();
|
||||||
|
|
||||||
// on external social login
|
// Lazy: SocialAuthService is providedIn:'root' and needs SocialAuthServiceConfig.
|
||||||
this.externalAuthService.authState.subscribe((user) => {
|
// Avoid constructor injection so password login works when Google is not configured.
|
||||||
if (user?.idToken) {
|
if (environment.externalLogins?.google?.clientId) {
|
||||||
oidcHelperService.loginByExternalLogin('google', user.idToken);
|
const social = this.injector.get(SocialAuthService, null);
|
||||||
}
|
social?.authState.subscribe((user) => {
|
||||||
});
|
if (user?.idToken) {
|
||||||
|
oidcHelperService.loginByExternalLogin('google', user.idToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.oidcHelperService.isDoneLoading$
|
this.oidcHelperService.isDoneLoading$
|
||||||
.pipe(
|
.pipe(
|
||||||
@@ -155,19 +160,15 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginGoogle(redirectUrl?: string): Observable<any> {
|
loginGoogle(redirectUrl?: string): Observable<any> {
|
||||||
return from(this.externalAuthService.signIn(GoogleLoginProvider.PROVIDER_ID));
|
const social = this.injector.get(SocialAuthService, null);
|
||||||
|
if (!social) {
|
||||||
|
return throwError(() => new Error('Google login is not configured'));
|
||||||
|
}
|
||||||
|
return from(social.signIn(GoogleLoginProvider.PROVIDER_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
attachGoogle(): Observable<any> {
|
attachGoogle(): Observable<any> {
|
||||||
var result = new Subject();
|
return new Subject();
|
||||||
|
|
||||||
/*this.externalAuthService.signIn(GoogleLoginProvider.PROVIDER_ID).then(function (resp) {
|
|
||||||
//console.log('attachGoogle', resp);
|
|
||||||
//return result.next(resp);
|
|
||||||
//this.attach(idToken.__raw, result);
|
|
||||||
});*/
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loginAuth0(): Observable<GeneralResultModel> {
|
loginAuth0(): Observable<GeneralResultModel> {
|
||||||
@@ -182,14 +183,12 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
subject.next({ success: login.success, error: login.error });
|
subject.next({ success: login.success, error: login.error });
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
//subject.next({ success: false, error: { description: 'Login failed' } });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.auth0Service.getAccessTokenWithPopup().subscribe(popupToken => {
|
this.auth0Service.getAccessTokenWithPopup().subscribe(popupToken => {
|
||||||
if (!popupToken) {
|
if (!popupToken) {
|
||||||
this.auth0Service.getAccessTokenSilently().subscribe(silently => {
|
this.auth0Service.getAccessTokenSilently().subscribe(() => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -203,7 +202,7 @@ export class AuthService {
|
|||||||
subs.unsubscribe();
|
subs.unsubscribe();
|
||||||
|
|
||||||
this.attach(token?.__raw).subscribe(
|
this.attach(token?.__raw).subscribe(
|
||||||
(resp) => subject.next({ success: true, data: token?.__raw }),
|
() => subject.next({ success: true, data: token?.__raw }),
|
||||||
(err) => subject.next({ success: false, data: err })
|
(err) => subject.next({ success: false, data: err })
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -213,7 +212,7 @@ export class AuthService {
|
|||||||
|
|
||||||
this.auth0Service.getAccessTokenWithPopup().subscribe(popupToken => {
|
this.auth0Service.getAccessTokenWithPopup().subscribe(popupToken => {
|
||||||
if (!popupToken) {
|
if (!popupToken) {
|
||||||
this.auth0Service.getAccessTokenSilently().subscribe(silently => {
|
this.auth0Service.getAccessTokenSilently().subscribe(() => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user