1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-08-31 00:01:03 +02:00

Use the helper methods in EnvironmentService (#1092)

This commit is contained in:
Oscar Hinton 2021-07-23 20:47:43 +02:00 committed by GitHub
parent 35d6a28c94
commit 2b5f61cadd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 33 deletions

2
jslib

@ -1 +1 @@
Subproject commit 8bf0f75d9e9869bbb8df397fb0c3bae4359eacf0
Subproject commit e1ce72136490b9055d8d6a03988e9d39ac560a89

View File

@ -7,6 +7,7 @@ import {
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
@ -36,9 +37,10 @@ export class RegisterComponent extends BaseRegisterComponent {
i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService, private route: ActivatedRoute,
stateService: StateService, platformUtilsService: PlatformUtilsService,
passwordGenerationService: PasswordGenerationService, private policyService: PolicyService) {
passwordGenerationService: PasswordGenerationService, private policyService: PolicyService,
environmentService: EnvironmentService) {
super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService,
passwordGenerationService);
passwordGenerationService, environmentService);
}
getPasswordScoreAlertDisplay() {

View File

@ -7,6 +7,7 @@ import {
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
@ -26,10 +27,10 @@ export class SsoComponent extends BaseSsoComponent {
i18nService: I18nService, route: ActivatedRoute,
storageService: StorageService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
cryptoFunctionService: CryptoFunctionService,
cryptoFunctionService: CryptoFunctionService, environmentService: EnvironmentService,
passwordGenerationService: PasswordGenerationService) {
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
apiService, cryptoFunctionService, passwordGenerationService);
apiService, cryptoFunctionService, environmentService, passwordGenerationService);
this.redirectUri = window.location.origin + '/sso-connector.html';
this.clientId = 'web';
}

View File

@ -34,12 +34,7 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
private environmentService: EnvironmentService) { }
ngOnInit() {
this.businessUrl = 'https://portal.bitwarden.com';
if (this.environmentService.enterpriseUrl != null) {
this.businessUrl = this.environmentService.enterpriseUrl;
} else if (this.environmentService.baseUrl != null) {
this.businessUrl = this.environmentService.baseUrl + '/portal';
}
this.businessUrl = this.environmentService.getEnterpriseUrl();
document.body.classList.remove('layout_frontend');
this.route.params.subscribe(async params => {

View File

@ -149,12 +149,7 @@ export class PoliciesComponent implements OnInit {
});
// Remove when removing deprecation warning
this.enterpriseUrl = 'https://portal.bitwarden.com';
if (this.environmentService.enterpriseUrl != null) {
this.enterpriseUrl = this.environmentService.enterpriseUrl;
} else if (this.environmentService.baseUrl != null) {
this.enterpriseUrl = this.environmentService.baseUrl + '/portal';
}
this.enterpriseUrl = this.environmentService.getEnterpriseUrl();
}
async load() {

View File

@ -103,7 +103,8 @@ const cryptoService = new CryptoService(storageService,
consoleLogService);
const tokenService = new TokenService(storageService);
const appIdService = new AppIdService(storageService);
const apiService = new ApiService(tokenService, platformUtilsService,
const environmentService = new EnvironmentService(storageService);
const apiService = new ApiService(tokenService, platformUtilsService, environmentService,
async (expired: boolean) => messagingService.send('logout', { expired: expired }));
const userService = new UserService(tokenService, storageService);
const settingsService = new SettingsService(userService, storageService);
@ -133,9 +134,8 @@ const authService = new AuthService(cryptoService, apiService,
const exportService = new ExportService(folderService, cipherService, apiService, cryptoService);
const importService = new ImportService(cipherService, folderService, apiService, i18nService, collectionService,
platformUtilsService, cryptoService);
const notificationsService = new NotificationsService(userService, syncService, appIdService,
apiService, vaultTimeoutService, async () => messagingService.send('logout', { expired: true }), consoleLogService);
const environmentService = new EnvironmentService(apiService, storageService, notificationsService);
const notificationsService = new NotificationsService(userService, syncService, appIdService, apiService, vaultTimeoutService,
environmentService, async () => messagingService.send('logout', { expired: true }), consoleLogService);
const auditService = new AuditService(cryptoFunctionService, apiService);
const eventLoggingService = new EventLoggingService(storageService, apiService, userService, cipherService);
const passwordRepromptService = new PasswordRepromptService(i18nService, cryptoService, platformUtilsService);
@ -147,19 +147,16 @@ export function initFactory(): Function {
await (storageService as HtmlStorageService).init();
if (process.env.ENV !== 'production' || platformUtilsService.isSelfHost()) {
environmentService.baseUrl = window.location.origin;
environmentService.setUrls({ base: window.location.origin }, false);
} else {
environmentService.notificationsUrl = 'https://notifications.bitwarden.com';
environmentService.enterpriseUrl = 'https://portal.bitwarden.com';
environmentService.setUrls({
base: window.location.origin,
notifications: 'https://notifications.bitwarden.com',
enterprise: 'https://portal.bitwarden.com',
}, false);
}
apiService.setUrls({
base: window.location.origin,
api: null,
identity: null,
events: null,
});
setTimeout(() => notificationsService.init(environmentService), 3000);
setTimeout(() => notificationsService.init(), 3000);
vaultTimeoutService.init(true);
const locale = await storageService.get<string>(ConstantsService.localeKey);

View File

@ -8,6 +8,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
@ -30,12 +31,12 @@ export class LinkSsoComponent extends SsoComponent implements AfterContentInit {
apiService: ApiService, authService: AuthService,
router: Router, route: ActivatedRoute,
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
storageService: StorageService, stateService: StateService) {
storageService: StorageService, stateService: StateService, environmentService: EnvironmentService) {
super(authService, router,
i18nService, route,
storageService, stateService,
platformUtilsService, apiService,
cryptoFunctionService, passwordGenerationService);
cryptoFunctionService, environmentService, passwordGenerationService);
this.returnUri = '/settings/organizations';
this.redirectUri = window.location.origin + '/sso-connector.html';