@@ -30,27 +30,29 @@ export class AuthService {
30
30
private router : Router ,
31
31
location : Location ,
32
32
) {
33
- this . oauthService . configure ( environment . authConfig ) ;
34
- this . oauthService . setupAutomaticSilentRefresh ( ) ;
35
- // If the user should not be forcefully logged in (e.g. if you have pages, which can be
36
- // accessed anonymously), change loadDiscoveryDocumentAndLogin to
37
- // loadDiscoveryDocumentAndTryLogin and have a login functionality in the
38
- // template of the component injecting the AuthService which calls the login() method.
39
- this . initialized = this . oauthService
40
- . loadDiscoveryDocumentAndLogin ( { state : location . path ( ) } )
41
- // If the user is not logged in, he will be forwarded to the identity provider
42
- // and this promise will not resolve. After being redirected from the identity
43
- // provider, the login promise will return true.
44
- . then ( ( v ) => ( v ? true : new Promise ( ( ) => { } ) ) ) ;
45
- // Redirect the user to the url configured with state above or in a separate login call.
46
- this . oauthService . events
47
- . pipe ( first ( ( e ) => e . type === "token_received" ) )
48
- . subscribe ( ( ) => {
49
- const state = decodeURIComponent ( this . oauthService . state || "" ) ;
50
- if ( state && state !== "/" ) {
51
- this . router . navigate ( [ state ] ) ;
52
- }
53
- } ) ;
33
+ if ( ! environment . disableBackend ) {
34
+ this . oauthService . configure ( environment . authConfig ) ;
35
+ this . oauthService . setupAutomaticSilentRefresh ( ) ;
36
+ // If the user should not be forcefully logged in (e.g. if you have pages, which can be
37
+ // accessed anonymously), change loadDiscoveryDocumentAndLogin to
38
+ // loadDiscoveryDocumentAndTryLogin and have a login functionality in the
39
+ // template of the component injecting the AuthService which calls the login() method.
40
+ this . initialized = this . oauthService
41
+ . loadDiscoveryDocumentAndLogin ( { state : location . path ( ) } )
42
+ // If the user is not logged in, he will be forwarded to the identity provider
43
+ // and this promise will not resolve. After being redirected from the identity
44
+ // provider, the login promise will return true.
45
+ . then ( ( v ) => ( v ? true : new Promise ( ( ) => { } ) ) ) ;
46
+ // Redirect the user to the url configured with state above or in a separate login call.
47
+ this . oauthService . events
48
+ . pipe ( first ( ( e ) => e . type === "token_received" ) )
49
+ . subscribe ( ( ) => {
50
+ const state = decodeURIComponent ( this . oauthService . state || "" ) ;
51
+ if ( state && state !== "/" ) {
52
+ this . router . navigate ( [ state ] ) ;
53
+ }
54
+ } ) ;
55
+ }
54
56
}
55
57
56
58
logOut ( ) {
0 commit comments