@@ -15,6 +15,8 @@ import { ClusterDomainWithToken } from 'src/app/core/models/misc/token.model';
15
15
import { StorageService } from 'src/app/core/services/common/storage.service' ;
16
16
import { NetsuiteAuthService } from 'src/app/core/services/netsuite/netsuite-core/netsuite-auth.service' ;
17
17
import { XeroAuthService } from 'src/app/core/services/xero/xero-core/xero-auth.service' ;
18
+ import { exposeAppConfig } from 'src/app/branding/expose-app-config' ;
19
+ import { brandingConfig } from 'src/app/branding/branding-config' ;
18
20
19
21
@Component ( {
20
22
selector : 'app-login' ,
@@ -23,6 +25,12 @@ import { XeroAuthService } from 'src/app/core/services/xero/xero-core/xero-auth.
23
25
} )
24
26
export class LoginComponent implements OnInit {
25
27
28
+ readonly brandingConfig = brandingConfig ;
29
+
30
+ readonly isINCluster = this . storageService . get ( 'cluster-domain' ) . includes ( 'in1' ) ;
31
+
32
+ readonly exposeApps = ! this . isINCluster ? exposeAppConfig [ brandingConfig . brandId ] [ brandingConfig . envId ] : exposeAppConfig [ brandingConfig . brandId ] [ 'production-1-in' ] ;
33
+
26
34
constructor (
27
35
private authService : AuthService ,
28
36
private businessCentralAuthService : BusinessCentralAuthService ,
@@ -64,26 +72,40 @@ export class LoginComponent implements OnInit {
64
72
} ;
65
73
this . userService . storeUserProfile ( user ) ;
66
74
67
- this . helperService . setBaseApiURL ( AppUrl . QBD ) ;
68
- this . qbdAuthService . qbdLogin ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
75
+ if ( this . exposeApps . QBD ) {
76
+ this . helperService . setBaseApiURL ( AppUrl . QBD ) ;
77
+ this . qbdAuthService . qbdLogin ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
78
+ }
69
79
70
- this . helperService . setBaseApiURL ( AppUrl . SAGE300 ) ;
71
- this . sage300AuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
80
+ if ( this . exposeApps . SAGE300 ) {
81
+ this . helperService . setBaseApiURL ( AppUrl . SAGE300 ) ;
82
+ this . sage300AuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
83
+ }
72
84
73
- this . helperService . setBaseApiURL ( AppUrl . BUSINESS_CENTRAL ) ;
74
- this . businessCentralAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
85
+ if ( this . exposeApps . BUSINESS_CENTRAL ) {
86
+ this . helperService . setBaseApiURL ( AppUrl . BUSINESS_CENTRAL ) ;
87
+ this . businessCentralAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
88
+ }
75
89
76
90
// Only local dev needs this, login happens via postMessage for prod/staging through webapp
77
91
if ( ! environment . production ) {
78
92
this . userService . storeUserProfile ( user ) ;
79
- this . helperService . setBaseApiURL ( AppUrl . QBO ) ;
80
- this . qboAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
81
- this . helperService . setBaseApiURL ( AppUrl . INTACCT ) ;
82
- this . siAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
83
- this . helperService . setBaseApiURL ( AppUrl . NETSUITE ) ;
84
- this . netsuiteAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
85
- this . helperService . setBaseApiURL ( AppUrl . XERO ) ;
86
- this . xeroAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
93
+ if ( this . exposeApps . QBO ) {
94
+ this . helperService . setBaseApiURL ( AppUrl . QBO ) ;
95
+ this . qboAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
96
+ }
97
+ if ( this . exposeApps . INTACCT ) {
98
+ this . helperService . setBaseApiURL ( AppUrl . INTACCT ) ;
99
+ this . siAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
100
+ }
101
+ if ( this . exposeApps . NETSUITE ) {
102
+ this . helperService . setBaseApiURL ( AppUrl . NETSUITE ) ;
103
+ this . netsuiteAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
104
+ }
105
+ if ( this . exposeApps . XERO ) {
106
+ this . helperService . setBaseApiURL ( AppUrl . XERO ) ;
107
+ this . xeroAuthService . loginWithRefreshToken ( clusterDomainWithToken . tokens . refresh_token ) . subscribe ( ) ;
108
+ }
87
109
this . redirect ( redirectUri ) ;
88
110
} else {
89
111
this . redirect ( redirectUri ) ;
0 commit comments