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 { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client';
|
||||
import { NgScrollbarModule } from 'ngx-scrollbar';
|
||||
import { SocialAuthService, SocialLoginModule } from '@abacritt/angularx-social-login';
|
||||
import { SocialLoginModule } from '@abacritt/angularx-social-login';
|
||||
|
||||
// app
|
||||
import { CoreModule } from './core/core.module';
|
||||
@@ -17,13 +17,31 @@ import { AppRoutingModule } from './app-routing.module';
|
||||
import { ErrorInterceptor } from './core/interceptor/error.interceptor';
|
||||
import { UpdateDateHttpInterceptor } from './core/interceptor/update.date.http.interceptor ';
|
||||
import { ExternalLoginConfig } from './config.external-login';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
export function createTranslateLoader(http: HttpClient) {
|
||||
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 = {
|
||||
providers: [
|
||||
...socialProviders,
|
||||
importProvidersFrom(
|
||||
BrowserAnimationsModule,
|
||||
AppRoutingModule,
|
||||
@@ -38,14 +56,7 @@ export const appConfig: ApplicationConfig = {
|
||||
},
|
||||
}),
|
||||
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: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, 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 { LockedComponent } from './locked/locked.component';
|
||||
import { ForgotPasswordComponent } from './forgot-password/forgot-password.component';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
const googleButtonImports = environment.externalLogins?.google?.clientId
|
||||
? [GoogleSigninButtonModule]
|
||||
: [];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -30,7 +35,7 @@ import { ForgotPasswordComponent } from './forgot-password/forgot-password.compo
|
||||
MatInputModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
GoogleSigninButtonModule,
|
||||
...googleButtonImports,
|
||||
],
|
||||
declarations: [
|
||||
Page500Component,
|
||||
|
||||
@@ -3,9 +3,6 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
// libs
|
||||
import { SocialAuthService } from '@abacritt/angularx-social-login';
|
||||
|
||||
// app
|
||||
import { AuthService } from 'src/app/core/service/auth.service';
|
||||
import { UnsubscribeOnDestroyAdapter } from 'src/app/shared/UnsubscribeOnDestroyAdapter';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// angular
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Router } 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 { getSafeRedirectUrl } from '../utils/safe-redirect';
|
||||
import { SubjectExtensions } from '../extensions/general.extensions';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
export function authAppInitializerFactory(authService: AuthService): () => Promise<void> {
|
||||
if (window.location.href.indexOf('/silent-refresh.html') !== -1) {
|
||||
@@ -52,17 +53,21 @@ export class AuthService {
|
||||
private route: ActivatedRoute,
|
||||
private oidcHelperService: OidcHelperService,
|
||||
private auth0Service: Auth0Service,
|
||||
private externalAuthService: SocialAuthService,
|
||||
private injector: Injector,
|
||||
) {
|
||||
this.currentUserSubject = new BehaviorSubject<UserModel>({} as UserModel);
|
||||
this.currentUser$ = this.currentUserSubject.asObservable();
|
||||
|
||||
// on external social login
|
||||
this.externalAuthService.authState.subscribe((user) => {
|
||||
// Lazy: SocialAuthService is providedIn:'root' and needs SocialAuthServiceConfig.
|
||||
// Avoid constructor injection so password login works when Google is not configured.
|
||||
if (environment.externalLogins?.google?.clientId) {
|
||||
const social = this.injector.get(SocialAuthService, null);
|
||||
social?.authState.subscribe((user) => {
|
||||
if (user?.idToken) {
|
||||
oidcHelperService.loginByExternalLogin('google', user.idToken);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.oidcHelperService.isDoneLoading$
|
||||
.pipe(
|
||||
@@ -155,19 +160,15 @@ export class AuthService {
|
||||
}
|
||||
|
||||
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> {
|
||||
var result = 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;
|
||||
return new Subject();
|
||||
}
|
||||
|
||||
loginAuth0(): Observable<GeneralResultModel> {
|
||||
@@ -182,14 +183,12 @@ export class AuthService {
|
||||
}
|
||||
subject.next({ success: login.success, error: login.error });
|
||||
});
|
||||
} else {
|
||||
//subject.next({ success: false, error: { description: 'Login failed' } });
|
||||
}
|
||||
});
|
||||
|
||||
this.auth0Service.getAccessTokenWithPopup().subscribe(popupToken => {
|
||||
if (!popupToken) {
|
||||
this.auth0Service.getAccessTokenSilently().subscribe(silently => {
|
||||
this.auth0Service.getAccessTokenSilently().subscribe(() => {
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -203,7 +202,7 @@ export class AuthService {
|
||||
subs.unsubscribe();
|
||||
|
||||
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 })
|
||||
);
|
||||
} else {
|
||||
@@ -213,7 +212,7 @@ export class AuthService {
|
||||
|
||||
this.auth0Service.getAccessTokenWithPopup().subscribe(popupToken => {
|
||||
if (!popupToken) {
|
||||
this.auth0Service.getAccessTokenSilently().subscribe(silently => {
|
||||
this.auth0Service.getAccessTokenSilently().subscribe(() => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user