1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

[Account Switching] [Refactor] Implement new account centric services (#1220)

* [chore] updated services.module to use account services

* [refactor] sorted services provided by services.module

* [chore] removed references to deleted jslib services

* [chore] used activeAccount over storageService for account level storage items

* [chore] resolved linter warnings

* Refactor activeAccountService to stateService

* [bug] Remove uneeded calls to state service on logout

This was causing console erros on logout. Clearing of data is handled fully in dedicated services, clearing them in state afterwards is essentially a redundant call.

* [bug] Add back null locked callback to VaultTimeoutService

* Move call to get showUpdateKey

* [bug] Ensure HtmlStorageService does not override StateService options and locations

* [bug] Adjust theme logic to pull from the new storage locations

* [bug] Correct theme not sticking on refresh

* [bug] Add enableFullWidth to the account model

* [bug] fix theme option empty when light is selected

* [bug] init state on application start

* [bug] Reinit state when coming back from a lock

* [style] Fix lint complaints

* [bug] Clean state on logout

* [chore] Resolved merge issues

* [bug] Correct default for enableGravitars

* Bump angular to 12.

* Remove angular.json

* Bump rxjs

* Fix build errors, remove file-loader with asset/resource

* Use contenthash

* Bump jslib

* Bump ngx-toastr

* [chore] resolve issues from merge

* [chore] resolve issues from merge

* [bug] Add missing bracket

* Use newer import syntax

* [bug] Correct service orge

* [style] Fix lint complaints

* [chore] update jslib

* [review] Address code review

* [review] Address code review

* [review] Rename providerService to webProviderService

Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
Co-authored-by: Hinton <oscar@oscarhinton.com>
This commit is contained in:
Addison Beck 2021-12-14 11:10:26 -05:00 committed by GitHub
parent 71075cf878
commit 17ae5ee57c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
101 changed files with 839 additions and 649 deletions

View File

@ -7,8 +7,8 @@ import { ActivatedRoute } from '@angular/router';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { Organization } from 'jslib-common/models/domain/organization';
@ -81,7 +81,7 @@ export class SsoComponent implements OnInit {
constructor(private fb: FormBuilder, private route: ActivatedRoute, private apiService: ApiService,
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private userService: UserService) { }
private organizationService: OrganizationService) { }
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
@ -91,7 +91,7 @@ export class SsoComponent implements OnInit {
}
async load() {
this.organization = await this.userService.getOrganization(this.organizationId);
this.organization = await this.organizationService.get(this.organizationId);
const ssoSettings = await this.apiService.getOrganizationSso(this.organizationId);
this.data.patchValue(ssoSettings.data);

View File

@ -8,11 +8,11 @@ import {
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { ValidationService } from 'jslib-angular/services/validation.service';
import { ProviderService } from '../services/provider.service';
import { WebProviderService } from '../services/webProvider.service';
import { Organization } from 'jslib-common/models/domain/organization';
import { Provider } from 'jslib-common/models/domain/provider';
@ -31,9 +31,13 @@ export class AddOrganizationComponent implements OnInit {
formPromise: Promise<any>;
loading = true;
constructor(private userService: UserService, private providerService: ProviderService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
private validationService: ValidationService) { }
constructor(
private providerService: ProviderService,
private webProviderService: WebProviderService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private validationService: ValidationService
) { }
async ngOnInit() {
await this.load();
@ -44,7 +48,7 @@ export class AddOrganizationComponent implements OnInit {
return;
}
this.provider = await this.userService.getProvider(this.providerId);
this.provider = await this.providerService.get(this.providerId);
this.loading = false;
}
@ -63,7 +67,7 @@ export class AddOrganizationComponent implements OnInit {
}
try {
this.formPromise = this.providerService.addOrganizationToProvider(this.providerId, organization.id);
this.formPromise = this.webProviderService.addOrganizationToProvider(this.providerId, organization.id);
await this.formPromise;
} catch (e) {
this.validationService.showError(e);

View File

@ -11,9 +11,10 @@ import { first } from 'rxjs/operators';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { ValidationService } from 'jslib-angular/services/validation.service';
@ -26,7 +27,7 @@ import {
ProviderOrganizationOrganizationDetailsResponse
} from 'jslib-common/models/response/provider/providerOrganizationResponse';
import { ProviderService } from '../services/provider.service';
import { WebProviderService } from '../services/webProvider.service';
import { AddOrganizationComponent } from './add-organization.component';
@ -54,11 +55,19 @@ export class ClientsComponent implements OnInit {
protected actionPromise: Promise<any>;
private pagedClientsCount = 0;
constructor(private route: ActivatedRoute, private userService: UserService,
private apiService: ApiService, private searchService: SearchService,
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private validationService: ValidationService, private providerService: ProviderService,
private logService: LogService, private modalService: ModalService) { }
constructor(
private route: ActivatedRoute,
private providerService: ProviderService,
private apiService: ApiService,
private searchService: SearchService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private validationService: ValidationService,
private webProviderService: WebProviderService,
private logService: LogService,
private modalService: ModalService,
private organizationService: OrganizationService
) { }
async ngOnInit() {
this.route.parent.params.subscribe(async params => {
@ -75,8 +84,8 @@ export class ClientsComponent implements OnInit {
async load() {
const response = await this.apiService.getProviderClients(this.providerId);
this.clients = response.data != null && response.data.length > 0 ? response.data : [];
this.manageOrganizations = (await this.userService.getProvider(this.providerId)).type === ProviderUserType.ProviderAdmin;
const candidateOrgs = (await this.userService.getAllOrganizations()).filter(o => o.isOwner && o.providerId == null);
this.manageOrganizations = (await this.providerService.get(this.providerId)).type === ProviderUserType.ProviderAdmin;
const candidateOrgs = (await this.organizationService.getAll()).filter(o => o.isOwner && o.providerId == null);
const allowedOrgsIds = await Promise.all(candidateOrgs.map(o => this.apiService.getOrganization(o.id))).then(orgs =>
orgs.filter(o => !DisallowedPlanTypes.includes(o.planType))
.map(o => o.id));
@ -144,7 +153,7 @@ export class ClientsComponent implements OnInit {
return false;
}
this.actionPromise = this.providerService.detachOrganizastion(this.providerId, organization.id);
this.actionPromise = this.webProviderService.detachOrganizastion(this.providerId, organization.id);
try {
await this.actionPromise;
this.platformUtilsService.showToast('success', null,

View File

@ -8,7 +8,6 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderUserAcceptRequest } from 'jslib-common/models/request/provider/providerUserAcceptRequest';
@Component({
@ -22,10 +21,15 @@ export class AcceptProviderComponent extends BaseAcceptComponent {
requiredParameters = ['providerId', 'providerUserId', 'token'];
constructor(router: Router, i18nService: I18nService, route: ActivatedRoute,
userService: UserService, stateService: StateService, private apiService: ApiService,
platformUtilService: PlatformUtilsService) {
super(router, platformUtilService, i18nService, route, userService, stateService);
constructor(
router: Router,
i18nService: I18nService,
route: ActivatedRoute,
stateService: StateService,
private apiService: ApiService,
platformUtilService: PlatformUtilsService,
) {
super(router, platformUtilService, i18nService, route, stateService);
}
async authedHandler(qParams: any) {

View File

@ -9,7 +9,7 @@ import { ExportService } from 'jslib-common/abstractions/export.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
@ -30,17 +30,31 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
private providerUsersUserIdMap = new Map<string, any>();
private providerUsersIdMap = new Map<string, any>();
constructor(private apiService: ApiService, private route: ActivatedRoute, eventService: EventService,
i18nService: I18nService, private userService: UserService, exportService: ExportService,
platformUtilsService: PlatformUtilsService, private router: Router, logService: LogService,
private userNamePipe: UserNamePipe) {
super(eventService, i18nService, exportService, platformUtilsService, logService);
constructor(
private apiService: ApiService,
private route: ActivatedRoute,
eventService: EventService,
i18nService: I18nService,
private providerService: ProviderService,
exportService: ExportService,
platformUtilsService: PlatformUtilsService,
private router: Router,
logService: LogService,
private userNamePipe: UserNamePipe,
) {
super(
eventService,
i18nService,
exportService,
platformUtilsService,
logService,
);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.providerId = params.providerId;
const provider = await this.userService.getProvider(this.providerId);
const provider = await this.providerService.get(this.providerId);
if (provider == null || !provider.useEvents) {
this.router.navigate(['/providers', this.providerId]);
return;

View File

@ -4,7 +4,7 @@ import {
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { Provider } from 'jslib-common/models/domain/provider';
@ -16,11 +16,11 @@ export class ManageComponent implements OnInit {
provider: Provider;
accessEvents = false;
constructor(private route: ActivatedRoute, private userService: UserService) { }
constructor(private route: ActivatedRoute, private providerService: ProviderService) { }
ngOnInit() {
this.route.parent.params.subscribe(async params => {
this.provider = await this.userService.getProvider(params.providerId);
this.provider = await this.providerService.get(params.providerId);
this.accessEvents = this.provider.useEvents;
});
}

View File

@ -13,9 +13,9 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { ValidationService } from 'jslib-angular/services/validation.service';
@ -58,20 +58,41 @@ export class PeopleComponent extends BasePeopleComponent<ProviderUserUserDetails
providerId: string;
accessEvents = false;
constructor(apiService: ApiService, private route: ActivatedRoute,
i18nService: I18nService, modalService: ModalService,
constructor(
apiService: ApiService,
private route: ActivatedRoute,
i18nService: I18nService,
modalService: ModalService,
platformUtilsService: PlatformUtilsService,
cryptoService: CryptoService, private userService: UserService, private router: Router,
storageService: StorageService, searchService: SearchService, validationService: ValidationService,
logService: LogService, searchPipe: SearchPipe, userNamePipe: UserNamePipe) {
super(apiService, searchService, i18nService, platformUtilsService, cryptoService,
storageService, validationService, modalService, logService, searchPipe, userNamePipe);
cryptoService: CryptoService,
private router: Router,
searchService: SearchService,
validationService: ValidationService,
logService: LogService,
searchPipe: SearchPipe,
userNamePipe: UserNamePipe,
stateService: StateService,
private providerService: ProviderService,
) {
super(
apiService,
searchService,
i18nService,
platformUtilsService,
cryptoService,
validationService,
modalService,
logService,
searchPipe,
userNamePipe,
stateService,
);
}
ngOnInit() {
this.route.parent.params.subscribe(async params => {
this.providerId = params.providerId;
const provider = await this.userService.getProvider(this.providerId);
const provider = await this.providerService.get(this.providerId);
if (!provider.canManageUsers) {
this.router.navigate(['../'], { relativeTo: this.route });

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { Provider } from 'jslib-common/models/domain/provider';
@ -14,7 +14,7 @@ export class ProvidersLayoutComponent {
provider: Provider;
private providerId: string;
constructor(private route: ActivatedRoute, private userService: UserService) { }
constructor(private route: ActivatedRoute, private providerService: ProviderService) { }
ngOnInit() {
document.body.classList.remove('layout_frontend');
@ -25,7 +25,7 @@ export class ProvidersLayoutComponent {
}
async load() {
this.provider = await this.userService.getProvider(this.providerId);
this.provider = await this.providerService.get(this.providerId);
}
get showMenuBar() {

View File

@ -7,7 +7,7 @@ import { ModalService } from 'jslib-angular/services/modal.service';
import { ProviderGuardService } from './services/provider-guard.service';
import { ProviderTypeGuardService } from './services/provider-type-guard.service';
import { ProviderService } from './services/provider.service';
import { WebProviderService } from './services/webProvider.service';
import { ProvidersLayoutComponent } from './providers-layout.component';
import { ProvidersRoutingModule } from './providers-routing.module';
@ -57,7 +57,7 @@ import { OssModule } from 'src/app/oss.module';
UserAddEditComponent,
],
providers: [
ProviderService,
WebProviderService,
ProviderGuardService,
ProviderTypeGuardService,
],

View File

@ -7,15 +7,19 @@ import {
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
@Injectable()
export class ProviderGuardService implements CanActivate {
constructor(private userService: UserService, private router: Router,
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService) { }
constructor(
private router: Router,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private providerService: ProviderService,
) { }
async canActivate(route: ActivatedRouteSnapshot) {
const provider = await this.userService.getProvider(route.params.providerId);
const provider = await this.providerService.get(route.params.providerId);
if (provider == null) {
this.router.navigate(['/']);
return false;

View File

@ -5,16 +5,16 @@ import {
Router,
} from '@angular/router';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { Permissions } from 'jslib-common/enums/permissions';
@Injectable()
export class ProviderTypeGuardService implements CanActivate {
constructor(private userService: UserService, private router: Router) { }
constructor(private providerService: ProviderService, private router: Router) { }
async canActivate(route: ActivatedRouteSnapshot) {
const provider = await this.userService.getProvider(route.params.providerId);
const provider = await this.providerService.get(route.params.providerId);
const permissions = route.data == null ? null : route.data.permissions as Permissions[];
if (

View File

@ -7,7 +7,7 @@ import { SyncService } from 'jslib-common/abstractions/sync.service';
import { ProviderAddOrganizationRequest } from 'jslib-common/models/request/provider/providerAddOrganizationRequest';
@Injectable()
export class ProviderService {
export class WebProviderService {
constructor(private cryptoService: CryptoService, private syncService: SyncService, private apiService: ApiService) {}
async addOrganizationToProvider(providerId: string, organizationId: string) {

View File

@ -2,19 +2,19 @@ import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
@Component({
selector: 'provider-settings',
templateUrl: 'settings.component.html',
})
export class SettingsComponent {
constructor(private route: ActivatedRoute, private userService: UserService,
constructor(private route: ActivatedRoute, private providerService: ProviderService,
private platformUtilsService: PlatformUtilsService) { }
ngOnInit() {
this.route.parent.params.subscribe(async params => {
const provider = await this.userService.getProvider(params.providerId);
const provider = await this.providerService.get(params.providerId);
});
}
}

2
jslib

@ -1 +1 @@
Subproject commit 8fc3cf50d2967212ffbbf0d57cac71d0774aa2a8
Subproject commit f90b3456d5b3782c44c55a49b125ebda0b1cddc4

View File

@ -8,7 +8,6 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { EmergencyAccessAcceptRequest } from 'jslib-common/models/request/emergencyAccessAcceptRequest';
import { BaseAcceptComponent } from '../common/base.accept.component';
@ -24,11 +23,21 @@ export class AcceptEmergencyComponent extends BaseAcceptComponent {
protected failedShortMessage = 'emergencyInviteAcceptFailedShort';
protected failedMessage = 'emergencyInviteAcceptFailed';
constructor(router: Router, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, route: ActivatedRoute,
private apiService: ApiService, userService: UserService,
stateService: StateService) {
super(router, platformUtilsService, i18nService, route, userService, stateService);
constructor(
router: Router,
platformUtilsService: PlatformUtilsService,
i18nService: I18nService,
route: ActivatedRoute,
private apiService: ApiService,
stateService: StateService
) {
super(
router,
platformUtilsService,
i18nService,
route,
stateService
);
}
async authedHandler(qParams: any): Promise<void> {

View File

@ -11,7 +11,6 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationUserAcceptRequest } from 'jslib-common/models/request/organizationUserAcceptRequest';
import { OrganizationUserResetPasswordEnrollmentRequest } from 'jslib-common/models/request/organizationUserResetPasswordEnrollmentRequest';
@ -29,12 +28,24 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
protected requiredParameters: string[] = ['organizationId', 'organizationUserId', 'token'];
constructor(router: Router, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, route: ActivatedRoute,
private apiService: ApiService, userService: UserService,
stateService: StateService, private cryptoService: CryptoService,
private policyService: PolicyService, private logService: LogService) {
super(router, platformUtilsService, i18nService, route, userService, stateService);
constructor(
router: Router,
platformUtilsService: PlatformUtilsService,
i18nService: I18nService,
route: ActivatedRoute,
private apiService: ApiService,
stateService: StateService,
private cryptoService: CryptoService,
private policyService: PolicyService,
private logService: LogService
) {
super(
router,
platformUtilsService,
i18nService,
route,
stateService
);
}
async authedHandler(qParams: any): Promise<void> {
@ -60,10 +71,7 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
const resetRequest = new OrganizationUserResetPasswordEnrollmentRequest();
resetRequest.resetPasswordKey = encryptedKey.encryptedString;
// Get User Id
const userId = await this.userService.getUserId();
return this.apiService.putOrganizationUserResetPasswordEnrollment(qParams.organizationId, userId, resetRequest);
return this.apiService.putOrganizationUserResetPasswordEnrollment(qParams.organizationId, await this.stateService.getUserId(), resetRequest);
});
} else {
this.actionPromise = this.apiService.postOrganizationUserAccept(qParams.organizationId,
@ -74,7 +82,7 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
this.platformUtilService.showToast('success', this.i18nService.t('inviteAccepted'),
this.i18nService.t('inviteAcceptedDesc'), {timeout: 10000});
await this.stateService.remove('orgInvitation');
await this.stateService.setOrganizationInvitation(null);
this.router.navigate(['/vault']);
}
@ -84,7 +92,7 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
// Fix URL encoding of space issue with Angular
this.orgName = this.orgName.replace(/\+/g, ' ');
}
await this.stateService.save('orgInvitation', qParams);
await this.stateService.setOrganizationInvitation(qParams);
}
private async performResetPasswordAutoEnroll(qParams: any): Promise<boolean> {

View File

@ -13,8 +13,6 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { RouterService } from '../services/router.service';
@ -28,19 +26,18 @@ import { LockComponent as BaseLockComponent } from 'jslib-angular/components/loc
export class LockComponent extends BaseLockComponent {
constructor(router: Router, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
userService: UserService, cryptoService: CryptoService,
storageService: StorageService, vaultTimeoutService: VaultTimeoutService,
cryptoService: CryptoService, vaultTimeoutService: VaultTimeoutService,
environmentService: EnvironmentService, private routerService: RouterService,
stateService: StateService, apiService: ApiService, logService: LogService,
keyConnectorService: KeyConnectorService, ngZone: NgZone) {
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService,
storageService, vaultTimeoutService, environmentService, stateService, apiService, logService,
super(router, i18nService, platformUtilsService, messagingService, cryptoService,
vaultTimeoutService, environmentService, stateService, apiService, logService,
keyConnectorService, ngZone);
}
async ngOnInit() {
await super.ngOnInit();
this.onSuccessfulSubmit = () => {
this.onSuccessfulSubmit = async () => {
const previousUrl = this.routerService.getPreviousUrl();
if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) {
this.successRoute = previousUrl;

View File

@ -19,7 +19,6 @@ import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGen
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { LoginComponent as BaseLoginComponent } from 'jslib-angular/components/login.component';
@ -34,8 +33,7 @@ export class LoginComponent extends BaseLoginComponent {
showResetPasswordAutoEnrollWarning = false;
constructor(authService: AuthService, router: Router,
i18nService: I18nService, private route: ActivatedRoute,
storageService: StorageService, stateService: StateService,
i18nService: I18nService, private route: ActivatedRoute, stateService: StateService,
platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService,
passwordGenerationService: PasswordGenerationService, cryptoFunctionService: CryptoFunctionService,
private apiService: ApiService, private policyService: PolicyService, logService: LogService,
@ -44,7 +42,7 @@ export class LoginComponent extends BaseLoginComponent {
platformUtilsService, i18nService,
stateService, environmentService,
passwordGenerationService, cryptoFunctionService,
storageService, logService, ngZone);
logService, ngZone);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
}
@ -54,16 +52,16 @@ export class LoginComponent extends BaseLoginComponent {
this.email = qParams.email;
}
if (qParams.premium != null) {
this.stateService.save('loginRedirect', { route: '/settings/premium' });
this.stateService.setLoginRedirect({ route: '/settings/premium' });
} else if (qParams.org != null) {
this.stateService.save('loginRedirect',
this.stateService.setLoginRedirect(
{ route: '/settings/create-organization', qParams: { plan: qParams.org } });
}
// Are they coming from an email for sponsoring a families organization
if (qParams.sponsorshipToken != null) {
// After logging in redirect them to setup the families sponsorship
this.stateService.save('loginRedirect', {
this.stateService.setLoginRedirect({
route: '/setup/families-for-enterprise',
qParams: { token: qParams.sponsorshipToken },
});
@ -71,7 +69,7 @@ export class LoginComponent extends BaseLoginComponent {
await super.ngOnInit();
});
const invite = await this.stateService.get<any>('orgInvitation');
const invite = await this.stateService.getOrganizationInvitation();
if (invite != null) {
let policyList: Policy[] = null;
try {
@ -91,10 +89,10 @@ export class LoginComponent extends BaseLoginComponent {
}
async goAfterLogIn() {
const loginRedirect = await this.stateService.get<any>('loginRedirect');
const loginRedirect = await this.stateService.getLoginRedirect();
if (loginRedirect != null) {
this.router.navigate([loginRedirect.route], { queryParams: loginRedirect.qParams });
await this.stateService.remove('loginRedirect');
await this.stateService.setLoginRedirect(null);
} else {
this.router.navigate([this.successRoute]);
}

View File

@ -53,11 +53,11 @@ export class RegisterComponent extends BaseRegisterComponent {
this.email = qParams.email;
}
if (qParams.premium != null) {
this.stateService.save('loginRedirect', { route: '/settings/premium' });
this.stateService.setLoginRedirect({ route: '/settings/premium' });
} else if (qParams.org != null) {
this.showCreateOrgMessage = true;
this.referenceData.flow = qParams.org;
this.stateService.save('loginRedirect',
this.stateService.setLoginRedirect(
{ route: '/settings/create-organization', qParams: { plan: qParams.org } });
}
if (qParams.layout != null) {
@ -71,7 +71,7 @@ export class RegisterComponent extends BaseRegisterComponent {
// Are they coming from an email for sponsoring a families organization
if (qParams.sponsorshipToken != null) {
// After logging in redirect them to setup the families sponsorship
this.stateService.save('loginRedirect', {
this.stateService.setLoginRedirect({
route: '/setup/families-for-enterprise',
qParams: { token: qParams.sponsorshipToken },
});
@ -80,7 +80,7 @@ export class RegisterComponent extends BaseRegisterComponent {
this.referenceData.id = null;
}
});
const invite = await this.stateService.get<any>('orgInvitation');
const invite = await this.stateService.getOrganizationInvitation();
if (invite != null) {
try {
const policies = await this.apiService.getPoliciesByToken(invite.organizationId, invite.token,

View File

@ -11,8 +11,8 @@ import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import {
SetPasswordComponent as BaseSetPasswordComponent,
@ -25,10 +25,10 @@ import {
export class SetPasswordComponent extends BaseSetPasswordComponent {
constructor(apiService: ApiService, i18nService: I18nService,
cryptoService: CryptoService, messagingService: MessagingService,
userService: UserService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService, router: Router,
syncService: SyncService, route: ActivatedRoute) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route);
passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService,
policyService: PolicyService, router: Router,
syncService: SyncService, route: ActivatedRoute, stateService: StateService) {
super(i18nService, cryptoService, messagingService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route, stateService);
}
}

View File

@ -15,12 +15,9 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SsoComponent as BaseSsoComponent } from 'jslib-angular/components/sso.component';
const IdentifierStorageKey = 'ssoOrgIdentifier';
@Component({
selector: 'app-sso',
templateUrl: 'sso.component.html',
@ -28,11 +25,11 @@ const IdentifierStorageKey = 'ssoOrgIdentifier';
export class SsoComponent extends BaseSsoComponent {
constructor(authService: AuthService, router: Router,
i18nService: I18nService, route: ActivatedRoute,
storageService: StorageService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
cryptoFunctionService: CryptoFunctionService, environmentService: EnvironmentService,
passwordGenerationService: PasswordGenerationService, logService: LogService) {
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
stateService: StateService, platformUtilsService: PlatformUtilsService,
apiService: ApiService, cryptoFunctionService: CryptoFunctionService,
environmentService: EnvironmentService, passwordGenerationService: PasswordGenerationService,
logService: LogService) {
super(authService, router, i18nService, route, stateService, platformUtilsService,
apiService, cryptoFunctionService, environmentService, passwordGenerationService, logService);
this.redirectUri = window.location.origin + '/sso-connector.html';
this.clientId = 'web';
@ -44,7 +41,7 @@ export class SsoComponent extends BaseSsoComponent {
if (qParams.identifier != null) {
this.identifier = qParams.identifier;
} else {
const storedIdentifier = await this.storageService.get<string>(IdentifierStorageKey);
const storedIdentifier = await this.stateService.getSsoOrgIdentifier();
if (storedIdentifier != null) {
this.identifier = storedIdentifier;
}
@ -53,7 +50,7 @@ export class SsoComponent extends BaseSsoComponent {
}
async submit() {
await this.storageService.save(IdentifierStorageKey, this.identifier);
await this.stateService.setSsoOrganizationIdentifier(this.identifier);
if (this.clientId === 'browser') {
document.cookie = `ssoHandOffMessage=${this.i18nService.t('ssoHandOff')};SameSite=strict`;
}

View File

@ -13,9 +13,9 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -23,7 +23,6 @@ import { TwoFactorProviderType } from 'jslib-common/enums/twoFactorProviderType'
import { TwoFactorComponent as BaseTwoFactorComponent } from 'jslib-angular/components/two-factor.component';
import { LogService } from 'jslib-common/abstractions/log.service';
import { TwoFactorOptionsComponent } from './two-factor-options.component';
@Component({
@ -37,9 +36,9 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
i18nService: I18nService, apiService: ApiService,
platformUtilsService: PlatformUtilsService, stateService: StateService,
environmentService: EnvironmentService, private modalService: ModalService,
storageService: StorageService, route: ActivatedRoute, logService: LogService) {
route: ActivatedRoute, logService: LogService) {
super(authService, router, i18nService, apiService, platformUtilsService, window, environmentService,
stateService, storageService, route, logService);
stateService, route, logService);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
}
@ -57,10 +56,10 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
}
async goAfterLogIn() {
const loginRedirect = await this.stateService.get<any>('loginRedirect');
const loginRedirect = await this.stateService.getLoginRedirect();
if (loginRedirect != null) {
this.router.navigate([loginRedirect.route], { queryParams: loginRedirect.qParams });
await this.stateService.remove('loginRedirect');
await this.stateService.setLoginRedirect(null);
} else {
this.router.navigate([this.successRoute], {
queryParams: {

View File

@ -9,9 +9,9 @@ import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGen
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { UpdateTempPasswordComponent as BaseUpdateTempPasswordComponent } from 'jslib-angular/components/update-temp-password.component';
import { StateService } from 'jslib-common/abstractions/state.service';
@Component({
selector: 'app-update-temp-password',
@ -21,10 +21,9 @@ import { UpdateTempPasswordComponent as BaseUpdateTempPasswordComponent } from '
export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent {
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
passwordGenerationService: PasswordGenerationService, policyService: PolicyService,
cryptoService: CryptoService, userService: UserService,
messagingService: MessagingService, apiService: ApiService,
syncService: SyncService, logService: LogService) {
cryptoService: CryptoService, messagingService: MessagingService,
apiService: ApiService, logService: LogService, stateService: StateService, syncService: SyncService) {
super(i18nService, platformUtilsService, passwordGenerationService, policyService, cryptoService,
userService, messagingService, apiService, syncService, logService);
messagingService, apiService, stateService, syncService, logService);
}
}

View File

@ -13,7 +13,7 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { VerifyEmailRequest } from 'jslib-common/models/request/verifyEmailRequest';
@ -22,10 +22,15 @@ import { VerifyEmailRequest } from 'jslib-common/models/request/verifyEmailReque
templateUrl: 'verify-email-token.component.html',
})
export class VerifyEmailTokenComponent implements OnInit {
constructor(private router: Router, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private route: ActivatedRoute,
private apiService: ApiService, private userService: UserService,
private logService: LogService) { }
constructor(
private router: Router,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private route: ActivatedRoute,
private apiService: ApiService,
private logService: LogService,
private stateService: StateService
) { }
ngOnInit() {
this.route.queryParams.pipe(first()).subscribe(async qParams => {
@ -33,8 +38,7 @@ export class VerifyEmailTokenComponent implements OnInit {
try {
await this.apiService.postAccountVerifyEmailToken(
new VerifyEmailRequest(qParams.userId, qParams.token));
const authed = await this.userService.isAuthenticated();
if (authed) {
if (await this.stateService.getIsAuthenticated()) {
await this.apiService.refreshIdentityToken();
}
this.platformUtilsService.showToast('success', null, this.i18nService.t('emailVerified'));

View File

@ -33,11 +33,8 @@ import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { PolicyListService } from './services/policy-list.service';
import { RouterService } from './services/router.service';
@ -65,20 +62,32 @@ export class AppComponent implements OnDestroy, OnInit {
private isIdle = false;
constructor(
private broadcasterService: BroadcasterService, private userService: UserService,
private tokenService: TokenService, private folderService: FolderService,
private settingsService: SettingsService, private syncService: SyncService,
private passwordGenerationService: PasswordGenerationService, private cipherService: CipherService,
private authService: AuthService, private router: Router,
private toastrService: ToastrService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private ngZone: NgZone,
private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService,
private cryptoService: CryptoService, private collectionService: CollectionService,
private sanitizer: DomSanitizer, private searchService: SearchService,
private notificationsService: NotificationsService, private routerService: RouterService,
private stateService: StateService, private eventService: EventService,
private policyService: PolicyService, protected policyListService: PolicyListService,
private keyConnectorService: KeyConnectorService) { }
private broadcasterService: BroadcasterService,
private tokenService: TokenService,
private folderService: FolderService,
private settingsService: SettingsService,
private syncService: SyncService,
private passwordGenerationService: PasswordGenerationService,
private cipherService: CipherService,
private authService: AuthService,
private router: Router,
private toastrService: ToastrService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private ngZone: NgZone,
private vaultTimeoutService: VaultTimeoutService,
private cryptoService: CryptoService,
private collectionService: CollectionService,
private sanitizer: DomSanitizer,
private searchService: SearchService,
private notificationsService: NotificationsService,
private routerService: RouterService,
private stateService: StateService,
private eventService: EventService,
private policyService: PolicyService,
protected policyListService: PolicyListService,
private keyConnectorService: KeyConnectorService
) { }
ngOnInit() {
this.ngZone.runOutsideAngular(() => {
@ -193,21 +202,18 @@ export class AppComponent implements OnDestroy, OnInit {
private async logOut(expired: boolean) {
await this.eventService.uploadEvents();
const userId = await this.userService.getUserId();
const userId = await this.stateService.getUserId();
await Promise.all([
this.eventService.clearEvents(),
this.syncService.setLastSync(new Date(0)),
this.tokenService.clearToken(),
this.cryptoService.clearKeys(),
this.userService.clear(),
this.settingsService.clear(userId),
this.cipherService.clear(userId),
this.folderService.clear(userId),
this.collectionService.clear(userId),
this.policyService.clear(userId),
this.passwordGenerationService.clear(),
this.stateService.purge(),
this.keyConnectorService.clear(),
]);
@ -218,6 +224,7 @@ export class AppComponent implements OnDestroy, OnInit {
this.i18nService.t('loginExpired'));
}
await this.stateService.clean({ userId: userId });
Swal.close();
this.router.navigate(['/']);
});
@ -230,8 +237,7 @@ export class AppComponent implements OnDestroy, OnInit {
}
this.lastActivity = now;
this.storageService.save(ConstantsService.lastActiveKey, now);
this.stateService.setLastActive(now);
// Idle states
if (this.isIdle) {
this.isIdle = false;
@ -284,7 +290,7 @@ export class AppComponent implements OnDestroy, OnInit {
}
private async setFullWidth() {
const enableFullWidth = await this.storageService.get<boolean>('enableFullWidth');
const enableFullWidth = await this.stateService.getEnableFullWidth();
if (enableFullWidth) {
document.body.classList.add('full-width');
} else {

View File

@ -12,7 +12,6 @@ import { first } from 'rxjs/operators';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
@Directive()
export abstract class BaseAcceptComponent implements OnInit {
@ -27,19 +26,18 @@ export abstract class BaseAcceptComponent implements OnInit {
constructor(protected router: Router, protected platformUtilService: PlatformUtilsService,
protected i18nService: I18nService, protected route: ActivatedRoute,
protected userService: UserService, protected stateService: StateService) { }
protected stateService: StateService) { }
abstract authedHandler(qParams: any): Promise<void>;
abstract unauthedHandler(qParams: any): Promise<void>;
ngOnInit() {
this.route.queryParams.pipe(first()).subscribe(async qParams => {
await this.stateService.remove('loginRedirect');
await this.stateService.setLoginRedirect(null);
let error = this.requiredParameters.some(e => qParams?.[e] == null || qParams[e] === '');
let errorMessage: string = null;
if (!error) {
this.authed = await this.userService.isAuthenticated();
this.authed = await this.stateService.getIsAuthenticated();
if (this.authed) {
try {
@ -49,7 +47,7 @@ export abstract class BaseAcceptComponent implements OnInit {
errorMessage = e.message;
}
} else {
await this.stateService.save('loginRedirect', {
await this.stateService.setLoginRedirect({
route: this.getRedirectRoute(),
qParams: qParams,
});

View File

@ -4,18 +4,16 @@ import {
ViewContainerRef
} from '@angular/core';
import { ValidationService } from 'jslib-angular/services/validation.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { ValidationService } from 'jslib-angular/services/validation.service';
import { SearchPipe } from 'jslib-angular/pipes/search.pipe';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
@ -88,12 +86,19 @@ export abstract class BasePeopleComponent<UserType extends ProviderUserUserDetai
private pagedUsersCount = 0;
constructor(protected apiService: ApiService, private searchService: SearchService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
constructor(
protected apiService: ApiService,
private searchService: SearchService,
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService,
protected cryptoService: CryptoService,
private storageService: StorageService, protected validationService: ValidationService,
protected modalService: ModalService, private logService: LogService,
private searchPipe: SearchPipe, protected userNamePipe: UserNamePipe ) { }
protected validationService: ValidationService,
protected modalService: ModalService,
private logService: LogService,
private searchPipe: SearchPipe,
protected userNamePipe: UserNamePipe,
protected stateService: StateService,
) { }
abstract edit(user: UserType): void;
abstract getUsers(): Promise<ListResponse<UserType>>;
@ -247,7 +252,7 @@ export abstract class BasePeopleComponent<UserType extends ProviderUserUserDetai
const publicKeyResponse = await this.apiService.getUserPublicKey(user.userId);
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
const autoConfirm = await this.storageService.get<boolean>(ConstantsService.autoConfirmFingerprints);
const autoConfirm = await this.stateService.getAutoConfirmFingerPrints();
if (autoConfirm == null || !autoConfirm) {
const [modal] = await this.modalService.openViewRef(UserConfirmComponent, this.confirmModalRef, comp => {
comp.name = this.userNamePipe.transform(user);

View File

@ -5,9 +5,9 @@ import {
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { Provider } from 'jslib-common/models/domain/provider';
@ -22,7 +22,7 @@ export class NavbarComponent implements OnInit {
providers: Provider[] = [];
constructor(private messagingService: MessagingService, private platformUtilsService: PlatformUtilsService,
private tokenService: TokenService, private userService: UserService, private syncService: SyncService) {
private tokenService: TokenService, private providerService: ProviderService, private syncService: SyncService) {
this.selfHosted = this.platformUtilsService.isSelfHost();
}
@ -37,7 +37,7 @@ export class NavbarComponent implements OnInit {
if (await this.syncService.getLastSync() == null) {
await this.syncService.fullSync(false);
}
this.providers = await this.userService.getAllProviders();
this.providers = await this.providerService.getAll();
}
lock() {

View File

@ -7,8 +7,8 @@ import {
import { ActivatedRoute } from '@angular/router';
import { BroadcasterService } from 'jslib-common/abstractions/broadcaster.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { Organization } from 'jslib-common/models/domain/organization';
@ -23,7 +23,7 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
businessTokenPromise: Promise<any>;
private organizationId: string;
constructor(private route: ActivatedRoute, private userService: UserService,
constructor(private route: ActivatedRoute, private organizationService: OrganizationService,
private broadcasterService: BroadcasterService, private ngZone: NgZone) { }
ngOnInit() {
@ -48,7 +48,7 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
}
async load() {
this.organization = await this.userService.getOrganization(this.organizationId);
this.organization = await this.organizationService.get(this.organizationId);
}
get showMenuBar() {

View File

@ -10,8 +10,8 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { EncString } from 'jslib-common/models/domain/encString';
import { SymmetricCryptoKey } from 'jslib-common/models/domain/symmetricCryptoKey';
@ -45,13 +45,17 @@ export class CollectionAddEditComponent implements OnInit {
private orgKey: SymmetricCryptoKey;
constructor(private apiService: ApiService, private i18nService: I18nService,
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private cryptoService: CryptoService, private userService: UserService,
private logService: LogService) { }
private cryptoService: CryptoService,
private logService: LogService,
private organizationService: OrganizationService
) { }
async ngOnInit() {
const organization = await this.userService.getOrganization(this.organizationId);
const organization = await this.organizationService.get(this.organizationId);
this.accessGroups = organization.useGroups;
this.editMode = this.loading = this.collectionId != null;
if (this.accessGroups) {

View File

@ -12,9 +12,9 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -53,11 +53,17 @@ export class CollectionsComponent implements OnInit {
private pagedCollectionsCount = 0;
constructor(private apiService: ApiService, private route: ActivatedRoute,
private collectionService: CollectionService, private modalService: ModalService,
constructor(
private apiService: ApiService,
private route: ActivatedRoute,
private collectionService: CollectionService,
private modalService: ModalService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private userService: UserService,
private searchService: SearchService, private logService: LogService) { }
private platformUtilsService: PlatformUtilsService,
private searchService: SearchService,
private logService: LogService,
private organizationService: OrganizationService,
) { }
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
@ -70,7 +76,7 @@ export class CollectionsComponent implements OnInit {
}
async load() {
this.organization = await this.userService.getOrganization(this.organizationId);
this.organization = await this.organizationService.get(this.organizationId);
this.canCreate = this.organization.canCreateNewCollections;
const decryptCollections = async (r: ListResponse<CollectionResponse>) => {

View File

@ -10,8 +10,9 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { ExportService } from 'jslib-common/abstractions/export.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { Organization } from 'jslib-common/models/domain/organization';
import { EventResponse } from 'jslib-common/models/response/eventResponse';
@ -31,17 +32,32 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
private orgUsersUserIdMap = new Map<string, any>();
constructor(private apiService: ApiService, private route: ActivatedRoute, eventService: EventService,
i18nService: I18nService, private userService: UserService,
exportService: ExportService, platformUtilsService: PlatformUtilsService, private router: Router,
logService: LogService, private userNamePipe: UserNamePipe) {
super(eventService, i18nService, exportService, platformUtilsService, logService);
constructor(
private apiService: ApiService,
private route: ActivatedRoute,
eventService: EventService,
i18nService: I18nService,
exportService: ExportService,
platformUtilsService: PlatformUtilsService,
private router: Router,
logService: LogService,
private userNamePipe: UserNamePipe,
private organizationService: OrganizationService,
private providerService: ProviderService,
) {
super(
eventService,
i18nService,
exportService,
platformUtilsService,
logService
);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organizationId = params.organizationId;
this.organization = await this.userService.getOrganization(this.organizationId);
this.organization = await this.organizationService.get(this.organizationId);
if (this.organization == null || !this.organization.useEvents) {
this.router.navigate(['/organizations', this.organizationId]);
return;
@ -60,8 +76,8 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
if (this.organization.providerId != null) {
try {
const provider = await this.userService.getProvider(this.organization.providerId);
if (provider != null && (await this.userService.getProvider(this.organization.providerId)).canManageUsers) {
const provider = await this.providerService.get(this.organization.providerId);
if (provider != null && (await this.providerService.get(this.organization.providerId)).canManageUsers) {
const providerUsersResponse = await this.apiService.getProviderUsers(this.organization.providerId);
providerUsersResponse.data.forEach(u => {
const name = this.userNamePipe.transform(u);

View File

@ -14,9 +14,9 @@ import { first } from 'rxjs/operators';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -46,16 +46,22 @@ export class GroupsComponent implements OnInit {
private pagedGroupsCount = 0;
constructor(private apiService: ApiService, private route: ActivatedRoute,
private i18nService: I18nService, private modalService: ModalService,
constructor(
private apiService: ApiService,
private route: ActivatedRoute,
private i18nService: I18nService,
private modalService: ModalService,
private platformUtilsService: PlatformUtilsService,
private userService: UserService, private router: Router,
private searchService: SearchService, private logService: LogService) { }
private router: Router,
private searchService: SearchService,
private logService: LogService,
private organizationService: OrganizationService,
) { }
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organizationId = params.organizationId;
const organization = await this.userService.getOrganization(this.organizationId);
const organization = await this.organizationService.get(this.organizationId);
if (organization == null || !organization.useGroups) {
this.router.navigate(['/organizations', this.organizationId]);
return;

View File

@ -4,7 +4,7 @@ import {
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { Organization } from 'jslib-common/models/domain/organization';
@ -19,11 +19,11 @@ export class ManageComponent implements OnInit {
accessEvents: boolean = false;
accessSso: boolean = false;
constructor(private route: ActivatedRoute, private userService: UserService) {}
constructor(private route: ActivatedRoute, private organizationService: OrganizationService) {}
ngOnInit() {
this.route.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
this.accessPolicies = this.organization.usePolicies;
this.accessSso = this.organization.useSso;
this.accessEvents = this.organization.useEvents;

View File

@ -18,12 +18,12 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -78,21 +78,43 @@ export class PeopleComponent extends BasePeopleComponent<OrganizationUserUserDet
orgResetPasswordPolicyEnabled = false;
callingUserType: OrganizationUserType = null;
constructor(apiService: ApiService, private route: ActivatedRoute,
i18nService: I18nService, modalService: ModalService,
constructor(
apiService: ApiService,
private route: ActivatedRoute,
i18nService: I18nService,
modalService: ModalService,
platformUtilsService: PlatformUtilsService,
cryptoService: CryptoService, private userService: UserService, private router: Router,
storageService: StorageService, searchService: SearchService,
validationService: ValidationService, private policyService: PolicyService,
logService: LogService, searchPipe: SearchPipe, userNamePipe: UserNamePipe, private syncService: SyncService) {
super(apiService, searchService, i18nService, platformUtilsService, cryptoService,
storageService, validationService, modalService, logService, searchPipe, userNamePipe);
cryptoService: CryptoService,
private router: Router,
searchService: SearchService,
validationService: ValidationService,
private policyService: PolicyService,
logService: LogService,
searchPipe: SearchPipe,
userNamePipe: UserNamePipe,
private syncService: SyncService,
stateService: StateService,
private organizationService: OrganizationService,
) {
super(
apiService,
searchService,
i18nService,
platformUtilsService,
cryptoService,
validationService,
modalService,
logService,
searchPipe,
userNamePipe,
stateService,
);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organizationId = params.organizationId;
const organization = await this.userService.getOrganization(this.organizationId);
const organization = await this.organizationService.get(this.organizationId);
if (!organization.canManageUsers) {
this.router.navigate(['../collections'], { relativeTo: this.route });
return;

View File

@ -14,7 +14,7 @@ import { first } from 'rxjs/operators';
import { PolicyType } from 'jslib-common/enums/policyType';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -43,13 +43,13 @@ export class PoliciesComponent implements OnInit {
private policiesEnabledMap: Map<PolicyType, boolean> = new Map<PolicyType, boolean>();
constructor(private apiService: ApiService, private route: ActivatedRoute,
private modalService: ModalService, private userService: UserService,
private modalService: ModalService, private organizationService: OrganizationService,
private policyListService: PolicyListService, private router: Router) { }
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organizationId = params.organizationId;
this.organization = await this.userService.getOrganization(this.organizationId);
this.organization = await this.organizationService.get(this.organizationId);
if (this.organization == null || !this.organization.usePolicies) {
this.router.navigate(['/organizations', this.organizationId]);
return;

View File

@ -6,11 +6,9 @@ import {
Output,
} from '@angular/core';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { StateService } from 'jslib-common/abstractions/state.service';
@Component({
selector: 'app-user-confirm',
@ -27,8 +25,8 @@ export class UserConfirmComponent implements OnInit {
fingerprint: string;
formPromise: Promise<any>;
constructor(private cryptoService: CryptoService, private storageService: StorageService,
private logService: LogService) { }
constructor(private cryptoService: CryptoService, private logService: LogService,
private stateService: StateService) { }
async ngOnInit() {
try {
@ -50,7 +48,7 @@ export class UserConfirmComponent implements OnInit {
}
if (this.dontAskAgain) {
await this.storageService.save(ConstantsService.autoConfirmFingerprints, true);
await this.stateService.setAutoConfirmFingerprints(true);
}
this.onConfirmedUser.emit();

View File

@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PolicyType } from 'jslib-common/enums/policyType';
@ -33,7 +33,7 @@ export class MasterPasswordPolicyComponent extends BasePolicyComponent {
passwordScores: { name: string; value: number; }[];
showKeyConnectorInfo: boolean = false;
constructor(private fb: FormBuilder, i18nService: I18nService, private userService: UserService) {
constructor(private fb: FormBuilder, i18nService: I18nService, private organizationService: OrganizationService) {
super();
this.passwordScores = [
@ -48,7 +48,7 @@ export class MasterPasswordPolicyComponent extends BasePolicyComponent {
async ngOnInit() {
super.ngOnInit();
const organization = await this.userService.getOrganization(this.policyResponse.organizationId);
const organization = await this.organizationService.get(this.policyResponse.organizationId);
this.showKeyConnectorInfo = organization.keyConnectorEnabled;
}
}

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PolicyType } from 'jslib-common/enums/policyType';
@ -32,13 +32,13 @@ export class ResetPasswordPolicyComponent extends BasePolicyComponent {
defaultTypes: { name: string; value: string; }[];
showKeyConnectorInfo: boolean = false;
constructor(private fb: FormBuilder, private userService: UserService) {
constructor(private fb: FormBuilder, private organizationService: OrganizationService) {
super();
}
async ngOnInit() {
super.ngOnInit();
const organization = await this.userService.getOrganization(this.policyResponse.organizationId);
const organization = await this.organizationService.get(this.policyResponse.organizationId);
this.showKeyConnectorInfo = organization.keyConnectorEnabled;
}
}

View File

@ -11,8 +11,8 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PlanType } from 'jslib-common/enums/planType';
@ -44,7 +44,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
constructor(private apiService: ApiService, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private messagingService: MessagingService, private route: ActivatedRoute,
private userService: UserService, private logService: LogService) {
private organizationService: OrganizationService, private logService: LogService) {
this.selfHosted = platformUtilsService.isSelfHost();
}
@ -62,7 +62,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
}
this.loading = true;
this.userOrg = await this.userService.getOrganization(this.organizationId);
this.userOrg = await this.organizationService.get(this.organizationId);
this.sub = await this.apiService.getOrganizationSubscription(this.organizationId);
this.loading = false;
}

View File

@ -1,8 +1,8 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
@Component({
selector: 'app-org-settings',
@ -12,13 +12,13 @@ export class SettingsComponent {
access2fa = false;
selfHosted: boolean;
constructor(private route: ActivatedRoute, private userService: UserService,
constructor(private route: ActivatedRoute, private organizationService: OrganizationService,
private platformUtilsService: PlatformUtilsService) { }
ngOnInit() {
this.route.parent.params.subscribe(async params => {
this.selfHosted = await this.platformUtilsService.isSelfHost();
const organization = await this.userService.getOrganization(params.organizationId);
const organization = await this.organizationService.get(params.organizationId);
this.access2fa = organization.use2fa;
});
}

View File

@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -18,10 +18,10 @@ import { TwoFactorSetupComponent as BaseTwoFactorSetupComponent } from '../../se
templateUrl: '../../settings/two-factor-setup.component.html',
})
export class TwoFactorSetupComponent extends BaseTwoFactorSetupComponent {
constructor(apiService: ApiService, userService: UserService,
constructor(apiService: ApiService,
modalService: ModalService, messagingService: MessagingService,
policyService: PolicyService, private route: ActivatedRoute) {
super(apiService, userService, modalService, messagingService, policyService);
policyService: PolicyService, private route: ActivatedRoute, stateService: StateService) {
super(apiService, modalService, messagingService, policyService, stateService);
}
async ngOnInit() {

View File

@ -16,8 +16,8 @@ import { ValidationService } from 'jslib-angular/services/validation.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PlanSponsorshipType } from 'jslib-common/enums/planSponsorshipType';
import { PlanType } from 'jslib-common/enums/planType';
@ -65,7 +65,7 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit {
constructor(private router: Router, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private route: ActivatedRoute,
private apiService: ApiService, private syncService: SyncService,
private validationService: ValidationService, private userService: UserService,
private validationService: ValidationService, private organizationService: OrganizationService,
private modalService: ModalService) { }
async ngOnInit() {
@ -85,7 +85,7 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit {
this.badToken = !await this.apiService.postPreValidateSponsorshipToken(this.token);
this.loading = false;
this.existingFamilyOrganizations = (await this.userService.getAllOrganizations())
this.existingFamilyOrganizations = (await this.organizationService.getAll())
.filter(o => o.planProductType === ProductType.Families);
if (this.existingFamilyOrganizations.length === 0) {

View File

@ -4,8 +4,9 @@ import { ActivatedRoute } from '@angular/router';
import { AuditService } from 'jslib-common/abstractions/audit.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -16,6 +17,7 @@ import {
import { Cipher } from 'jslib-common/models/domain/cipher';
import { CipherView } from 'jslib-common/models/view/cipherView';
@Component({
selector: 'app-exposed-passwords-report',
templateUrl: '../../tools/exposed-passwords-report.component.html',
@ -24,15 +26,16 @@ export class ExposedPasswordsReportComponent extends BaseExposedPasswordsReportC
manageableCiphers: Cipher[];
constructor(cipherService: CipherService, auditService: AuditService,
modalService: ModalService, messagingService: MessagingService,
userService: UserService, passwordRepromptService: PasswordRepromptService, private route: ActivatedRoute) {
super(cipherService, auditService, modalService, messagingService, userService, passwordRepromptService);
modalService: ModalService, messagingService: MessagingService, stateService: StateService,
private organizationService: OrganizationService, private route: ActivatedRoute,
passwordRepromptService: PasswordRepromptService) {
super(cipherService, auditService, modalService, messagingService, stateService, passwordRepromptService);
}
ngOnInit() {
const dynamicSuper = Object.getPrototypeOf(this.constructor.prototype);
this.route.parent.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
this.manageableCiphers = await this.cipherService.getAll();
// TODO: We should do something about this, calling super in an async function is bad
dynamicSuper.ngOnInit();

View File

@ -7,9 +7,9 @@ import {
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { ImportService } from 'jslib-common/abstractions/import.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ImportComponent as BaseImportComponent } from '../../tools/import.component';
@ -20,11 +20,24 @@ import { ImportComponent as BaseImportComponent } from '../../tools/import.compo
export class ImportComponent extends BaseImportComponent {
organizationName: string;
constructor(i18nService: I18nService,
importService: ImportService, router: Router, private route: ActivatedRoute,
platformUtilsService: PlatformUtilsService, policyService: PolicyService,
private userService: UserService, logService: LogService) {
super(i18nService, importService, router, platformUtilsService, policyService, logService);
constructor(
i18nService: I18nService,
importService: ImportService,
router: Router,
private route: ActivatedRoute,
platformUtilsService: PlatformUtilsService,
policyService: PolicyService,
private organizationService: OrganizationService,
logService: LogService
) {
super(
i18nService,
importService,
router,
platformUtilsService,
policyService,
logService
);
}
async ngOnInit() {
@ -34,7 +47,7 @@ export class ImportComponent extends BaseImportComponent {
await super.ngOnInit();
this.importBlockedByPolicy = false;
});
const organization = await this.userService.getOrganization(this.organizationId);
const organization = await this.organizationService.get(this.organizationId);
this.organizationName = organization.name;
}

View File

@ -4,8 +4,9 @@ import { ActivatedRoute } from '@angular/router';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -15,20 +16,22 @@ import {
import { CipherView } from 'jslib-common/models/view/cipherView';
@Component({
selector: 'app-inactive-two-factor-report',
templateUrl: '../../tools/inactive-two-factor-report.component.html',
})
export class InactiveTwoFactorReportComponent extends BaseInactiveTwoFactorReportComponent {
constructor(cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService,
private route: ActivatedRoute, logService: LogService, passwordRepromptService: PasswordRepromptService) {
super(cipherService, modalService, messagingService, userService, logService, passwordRepromptService);
messagingService: MessagingService, stateService: StateService,
private route: ActivatedRoute, logService: LogService, passwordRepromptService: PasswordRepromptService,
private organizationService: OrganizationService) {
super(cipherService, modalService, messagingService, stateService, logService, passwordRepromptService);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
await super.ngOnInit();
});
}

View File

@ -3,8 +3,9 @@ import { ActivatedRoute } from '@angular/router';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -24,14 +25,15 @@ export class ReusedPasswordsReportComponent extends BaseReusedPasswordsReportCom
manageableCiphers: Cipher[];
constructor(cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService, passwordRepromptService: PasswordRepromptService,
private route: ActivatedRoute) {
super(cipherService, modalService, messagingService, userService, passwordRepromptService);
messagingService: MessagingService, stateService: StateService,
private route: ActivatedRoute, private organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService) {
super(cipherService, modalService, messagingService, stateService, passwordRepromptService);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
this.manageableCiphers = await this.cipherService.getAll();
await super.ngOnInit();
});

View File

@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { Organization } from 'jslib-common/models/domain/organization';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
@Component({
selector: 'app-org-tools',
@ -15,12 +15,12 @@ export class ToolsComponent {
accessReports = false;
loading = true;
constructor(private route: ActivatedRoute, private userService: UserService,
constructor(private route: ActivatedRoute, private organizationService: OrganizationService,
private messagingService: MessagingService) { }
ngOnInit() {
this.route.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
// TODO: Maybe we want to just make sure they are not on a free plan? Just compare useTotp for now
// since all paid plans include useTotp
this.accessReports = this.organization.useTotp;

View File

@ -3,8 +3,9 @@ import { ActivatedRoute } from '@angular/router';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -20,14 +21,15 @@ import { CipherView } from 'jslib-common/models/view/cipherView';
})
export class UnsecuredWebsitesReportComponent extends BaseUnsecuredWebsitesReportComponent {
constructor(cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService, passwordRepromptService: PasswordRepromptService,
private route: ActivatedRoute) {
super(cipherService, modalService, messagingService, userService, passwordRepromptService);
messagingService: MessagingService, stateService: StateService,
private route: ActivatedRoute, private organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService) {
super(cipherService, modalService, messagingService, stateService, passwordRepromptService);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
await super.ngOnInit();
});
}

View File

@ -3,9 +3,10 @@ import { ActivatedRoute } from '@angular/router';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -26,14 +27,14 @@ export class WeakPasswordsReportComponent extends BaseWeakPasswordsReportCompone
constructor(cipherService: CipherService, passwordGenerationService: PasswordGenerationService,
modalService: ModalService, messagingService: MessagingService,
userService: UserService, passwordRepromptService: PasswordRepromptService, private route: ActivatedRoute) {
super(cipherService, passwordGenerationService, modalService, messagingService, userService,
passwordRepromptService);
stateService: StateService, private route: ActivatedRoute,
private organizationService: OrganizationService, passwordRepromptService: PasswordRepromptService) {
super(cipherService, passwordGenerationService, modalService, messagingService, stateService, passwordRepromptService);
}
async ngOnInit() {
this.route.parent.parent.params.subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
this.manageableCiphers = await this.cipherService.getAll();
await super.ngOnInit();
});

View File

@ -9,13 +9,13 @@ import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { CipherData } from 'jslib-common/models/data/cipherData';
import { Cipher } from 'jslib-common/models/domain/cipher';
@ -36,14 +36,14 @@ export class AddEditComponent extends BaseAddEditComponent {
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
userService: UserService, collectionService: CollectionService,
totpService: TotpService, passwordGenerationService: PasswordGenerationService,
private apiService: ApiService, messagingService: MessagingService,
eventService: EventService, policyService: PolicyService, logService: LogService,
passwordRepromptService: PasswordRepromptService) {
collectionService: CollectionService, totpService: TotpService,
passwordGenerationService: PasswordGenerationService, private apiService: ApiService,
messagingService: MessagingService, eventService: EventService,
policyService: PolicyService, logService: LogService,
passwordRepromptService: PasswordRepromptService, organizationService: OrganizationService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, totpService, passwordGenerationService, messagingService,
eventService, policyService, passwordRepromptService, logService);
collectionService, totpService, passwordGenerationService, messagingService,
eventService, policyService, organizationService, logService, passwordRepromptService);
}
protected allowOwnershipAssignment() {

View File

@ -6,7 +6,7 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { CipherData } from 'jslib-common/models/data/cipherData';
import { Cipher } from 'jslib-common/models/domain/cipher';
@ -25,11 +25,9 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
organization: Organization;
constructor(cipherService: CipherService, i18nService: I18nService,
cryptoService: CryptoService, userService: UserService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
logService: LogService) {
super(cipherService, i18nService, cryptoService, userService, platformUtilsService, apiService,
logService);
cryptoService: CryptoService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService, logService: LogService) {
super(cipherService, i18nService, cryptoService, stateService, platformUtilsService, apiService, logService);
}
protected async reupload(attachment: AttachmentView) {

View File

@ -12,10 +12,11 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { Organization } from 'jslib-common/models/domain/organization';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CiphersComponent as BaseCiphersComponent } from '../../vault/ciphers.component';
@ -32,13 +33,29 @@ export class CiphersComponent extends BaseCiphersComponent {
protected allCiphers: CipherView[] = [];
constructor(searchService: SearchService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, cipherService: CipherService,
private apiService: ApiService, eventService: EventService, totpService: TotpService,
userService: UserService, passwordRepromptService: PasswordRepromptService,
logService: LogService) {
super(searchService, i18nService, platformUtilsService, cipherService,
eventService, totpService, userService, passwordRepromptService, logService);
constructor(
searchService: SearchService,
i18nService: I18nService,
platformUtilsService: PlatformUtilsService,
cipherService: CipherService,
private apiService: ApiService,
eventService: EventService,
totpService: TotpService,
passwordRepromptService: PasswordRepromptService,
logService: LogService,
stateService: StateService,
) {
super(
searchService,
i18nService,
platformUtilsService,
cipherService,
eventService,
totpService,
stateService,
passwordRepromptService,
logService
);
}
async load(filter: (cipher: CipherView) => boolean = null) {

View File

@ -4,8 +4,7 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { CollectionData } from 'jslib-common/models/data/collectionData';
import { Collection } from 'jslib-common/models/domain/collection';
@ -23,9 +22,9 @@ export class GroupingsComponent extends BaseGroupingsComponent {
organization: Organization;
constructor(collectionService: CollectionService, folderService: FolderService,
storageService: StorageService, userService: UserService,
private apiService: ApiService, private i18nService: I18nService) {
super(collectionService, folderService, storageService, userService);
stateService: StateService, private apiService: ApiService,
private i18nService: I18nService) {
super(collectionService, folderService, stateService);
}
async loadCollections() {
@ -52,8 +51,8 @@ export class GroupingsComponent extends BaseGroupingsComponent {
this.nestedCollections = await this.collectionService.getAllNested(this.collections);
}
collapse(grouping: CollectionView) {
super.collapse(grouping, 'org_');
async collapse(grouping: CollectionView) {
await super.collapse(grouping, 'org_');
}
isCollapsed(grouping: CollectionView) {

View File

@ -17,9 +17,9 @@ import { first } from 'rxjs/operators';
import { BroadcasterService } from 'jslib-common/abstractions/broadcaster.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -55,7 +55,7 @@ export class VaultComponent implements OnInit, OnDestroy {
deleted: boolean = false;
trashCleanupWarning: string = null;
constructor(private route: ActivatedRoute, private userService: UserService,
constructor(private route: ActivatedRoute, private organizationService: OrganizationService,
private router: Router, private changeDetectorRef: ChangeDetectorRef,
private syncService: SyncService, private i18nService: I18nService,
private modalService: ModalService, private messagingService: MessagingService,
@ -66,9 +66,8 @@ export class VaultComponent implements OnInit, OnDestroy {
this.trashCleanupWarning = this.i18nService.t(
this.platformUtilsService.isSelfHost() ? 'trashCleanupWarningSelfHosted' : 'trashCleanupWarning'
);
this.route.parent.params.pipe(first()).subscribe(async params => {
this.organization = await this.userService.getOrganization(params.organizationId);
this.organization = await this.organizationService.get(params.organizationId);
this.groupingsComponent.organization = this.organization;
this.ciphersComponent.organization = this.organization;

View File

@ -5,7 +5,7 @@ import {
} from '@angular/core';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { Provider } from 'jslib-common/models/domain/provider';
@ -22,7 +22,7 @@ export class ProvidersComponent implements OnInit {
loaded: boolean = false;
actionPromise: Promise<any>;
constructor(private userService: UserService, private i18nService: I18nService) { }
constructor(private providerService: ProviderService, private i18nService: I18nService) { }
async ngOnInit() {
document.body.classList.remove('layout_frontend');
@ -30,7 +30,7 @@ export class ProvidersComponent implements OnInit {
}
async load() {
const providers = await this.userService.getAllProviders();
const providers = await this.providerService.getAll();
providers.sort(Utils.getSortFunction(this.i18nService, 'name'));
this.providers = providers;
this.loaded = true;

View File

@ -4,14 +4,14 @@ import { Component } from '@angular/core';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { AddEditComponent as BaseAddEditComponent } from 'jslib-angular/components/send/add-edit.component';
import { LogService } from 'jslib-common/abstractions/log.service';
@Component({
selector: 'app-send-add-edit',
@ -20,11 +20,11 @@ import { LogService } from 'jslib-common/abstractions/log.service';
export class AddEditComponent extends BaseAddEditComponent {
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
environmentService: EnvironmentService, datePipe: DatePipe,
sendService: SendService, userService: UserService,
sendService: SendService, stateService: StateService,
messagingService: MessagingService, policyService: PolicyService,
logService: LogService) {
super(i18nService, platformUtilsService, environmentService, datePipe, sendService, userService,
messagingService, policyService, logService);
super(i18nService, platformUtilsService, environmentService, datePipe, sendService,
messagingService, policyService, logService, stateService);
}
async copyLinkToClipboard(link: string): Promise<void | boolean> {

View File

@ -19,7 +19,6 @@ import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.se
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -34,11 +33,11 @@ export class SendComponent extends BaseSendComponent {
constructor(sendService: SendService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService,
ngZone: NgZone, searchService: SearchService, policyService: PolicyService, userService: UserService,
private modalService: ModalService, private broadcasterService: BroadcasterService,
logService: LogService) {
ngZone: NgZone, searchService: SearchService,
policyService: PolicyService, private modalService: ModalService,
private broadcasterService: BroadcasterService, logService: LogService) {
super(sendService, i18nService, platformUtilsService, environmentService, ngZone, searchService,
policyService, userService, logService);
policyService, logService);
}
async ngOnInit() {

View File

@ -6,16 +6,20 @@ import {
} from '@angular/router';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
@Injectable()
export class OrganizationGuardService implements CanActivate {
constructor(private userService: UserService, private router: Router,
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService) { }
constructor(
private router: Router,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private organizationService: OrganizationService,
) { }
async canActivate(route: ActivatedRouteSnapshot) {
const org = await this.userService.getOrganization(route.params.organizationId);
const org = await this.organizationService.get(route.params.organizationId);
if (org == null) {
this.router.navigate(['/']);
return false;

View File

@ -5,16 +5,16 @@ import {
Router,
} from '@angular/router';
import { UserService } from 'jslib-common/abstractions/user.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { Permissions } from 'jslib-common/enums/permissions';
@Injectable()
export class OrganizationTypeGuardService implements CanActivate {
constructor(private userService: UserService, private router: Router) { }
constructor(private organizationService: OrganizationService, private router: Router) { }
async canActivate(route: ActivatedRouteSnapshot) {
const org = await this.userService.getOrganization(route.params.organizationId);
const org = await this.organizationService.get(route.params.organizationId);
const permissions = route.data == null ? null : route.data.permissions as Permissions[];
if (

View File

@ -22,7 +22,6 @@ import { JslibServicesModule } from 'jslib-angular/services/jslib-services.modul
import { ModalService as ModalServiceAbstraction } from 'jslib-angular/services/modal.service';
import { AuthService } from 'jslib-common/services/auth.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ContainerService } from 'jslib-common/services/container.service';
import { CryptoService } from 'jslib-common/services/crypto.service';
import { EventService as EventLoggingService } from 'jslib-common/services/event.service';
@ -57,6 +56,7 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
platformUtilsService: PlatformUtilsServiceAbstraction, cryptoService: CryptoServiceAbstraction): Function {
return async () => {
await (storageService as HtmlStorageService).init();
await stateService.init();
const urls = process.env.URLS as Urls;
urls.base ??= window.location.origin;
@ -65,7 +65,7 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
setTimeout(() => notificationsService.init(), 3000);
vaultTimeoutService.init(true);
const locale = await storageService.get<string>(ConstantsService.localeKey);
const locale = await stateService.getLocale();
await i18nService.init(locale);
eventLoggingService.init(true);
authService.init();
@ -74,17 +74,13 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
// Initial theme is set in index.html which must be updated if there are any changes to theming logic
platformUtilsService.onDefaultSystemThemeChange(async sysTheme => {
const bwTheme = await storageService.get<ThemeType>(ConstantsService.themeKey);
const bwTheme = await stateService.getTheme();
if (bwTheme === ThemeType.System) {
htmlEl.classList.remove('theme_' + ThemeType.Light, 'theme_' + ThemeType.Dark);
htmlEl.classList.add('theme_' + sysTheme);
}
});
stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey));
stateService.save('enableGravatars', await storageService.get<boolean>('enableGravatars'));
const containerService = new ContainerService(cryptoService);
containerService.attachToWindow(window);
};
@ -130,13 +126,13 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
{
provide: PlatformUtilsServiceAbstraction,
useFactory: (i18nService: I18nServiceAbstraction, messagingService: MessagingServiceAbstraction,
logService: LogService, injector: Injector) => new WebPlatformUtilsService(i18nService,
messagingService, logService, () => injector.get(StorageServiceAbstraction)),
logService: LogService, stateService: StateServiceAbstraction) => new WebPlatformUtilsService(i18nService,
messagingService, logService, stateService),
deps: [
I18nServiceAbstraction,
MessagingServiceAbstraction,
LogService,
Injector, // TODO: Get rid of circular dependency!
StateServiceAbstraction,
],
},
{ provide: MessagingServiceAbstraction, useClass: BroadcasterMessagingService },
@ -156,19 +152,12 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
},
{
provide: CryptoServiceAbstraction,
useFactory: (storageService: StorageServiceAbstraction, secureStorageService: StorageServiceAbstraction,
cryptoFunctionService: CryptoFunctionServiceAbstraction,
platformUtilsService: PlatformUtilsServiceAbstraction, logService: LogService) => {
const storageImplementation = platformUtilsService.isDev() ? storageService : secureStorageService;
return new CryptoService(storageService, storageImplementation, cryptoFunctionService,
platformUtilsService, logService);
},
useClass: CryptoService,
deps: [
StorageServiceAbstraction,
'SECURE_STORAGE',
CryptoFunctionServiceAbstraction,
PlatformUtilsServiceAbstraction,
LogService,
StateServiceAbstraction,
],
},
],

View File

@ -11,7 +11,7 @@ import { PurgeVaultComponent } from './purge-vault.component';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { KeyConnectorService } from 'jslib-common/abstractions/keyConnector.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -31,7 +31,7 @@ export class AccountComponent {
showChangeEmail = true;
constructor(private modalService: ModalService, private apiService: ApiService,
private userService: UserService, private keyConnectorService: KeyConnectorService) { }
private keyConnectorService: KeyConnectorService, private stateService: StateService) { }
async ngOnInit() {
this.showChangeEmail = this.showChangeKdf = this.showChangePassword =
@ -51,7 +51,7 @@ export class AccountComponent {
}
async viewUserApiKey() {
const entityId = await this.userService.getUserId();
const entityId = await this.stateService.getUserId();
await this.modalService.openViewRef(ApiKeyComponent, this.viewUserApiKeyModalRef, comp => {
comp.keyType = 'user';
comp.entityId = entityId;
@ -65,7 +65,7 @@ export class AccountComponent {
}
async rotateUserApiKey() {
const entityId = await this.userService.getUserId();
const entityId = await this.stateService.getUserId();
await this.modalService.openViewRef(ApiKeyComponent, this.rotateUserApiKeyModalRef, comp => {
comp.keyType = 'user';
comp.isRotation = true;

View File

@ -11,8 +11,9 @@ import {
import { ApiService } from 'jslib-common/abstractions/api.service';
import { PayPalConfig } from 'jslib-common/abstractions/environment.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { PaymentMethodType } from 'jslib-common/enums/paymentMethodType';
@ -45,8 +46,9 @@ export class AddCreditComponent implements OnInit {
private name: string;
private email: string;
constructor(private userService: UserService, private apiService: ApiService,
private platformUtilsService: PlatformUtilsService, private logService: LogService) {
constructor(private stateService: StateService, private apiService: ApiService,
private platformUtilsService: PlatformUtilsService, private organizationService: OrganizationService,
private logService: LogService) {
const payPalConfig = process.env.PAYPAL_CONFIG as PayPalConfig;
this.ppButtonFormAction = payPalConfig.buttonAction;
this.ppButtonBusinessId = payPalConfig.businessId;
@ -58,7 +60,7 @@ export class AddCreditComponent implements OnInit {
this.creditAmount = '20.00';
}
this.ppButtonCustomField = 'organization_id:' + this.organizationId;
const org = await this.userService.getOrganization(this.organizationId);
const org = await this.organizationService.get(this.organizationId);
if (org != null) {
this.subject = org.name;
this.name = org.name;
@ -67,8 +69,8 @@ export class AddCreditComponent implements OnInit {
if (this.creditAmount == null) {
this.creditAmount = '10.00';
}
this.userId = await this.userService.getUserId();
this.subject = await this.userService.getEmail();
this.userId = await this.stateService.getUserId();
this.subject = await this.stateService.getEmail();
this.email = this.subject;
this.ppButtonCustomField = 'user_id:' + this.userId;
}

View File

@ -9,7 +9,7 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { EmailRequest } from 'jslib-common/models/request/emailRequest';
import { EmailTokenRequest } from 'jslib-common/models/request/emailTokenRequest';
@ -29,10 +29,15 @@ export class ChangeEmailComponent implements OnInit {
formPromise: Promise<any>;
constructor(private apiService: ApiService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
private messagingService: MessagingService, private userService: UserService,
private logService: LogService) { }
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private cryptoService: CryptoService,
private messagingService: MessagingService,
private logService: LogService,
private stateService: StateService,
) { }
async ngOnInit() {
const twoFactorProviders = await this.apiService.getTwoFactorProviders();
@ -64,8 +69,8 @@ export class ChangeEmailComponent implements OnInit {
request.token = this.token;
request.newEmail = this.newEmail;
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null);
const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations();
const kdf = await this.stateService.getKdfType();
const kdfIterations = await this.stateService.getKdfIterations();
const newKey = await this.cryptoService.makeKey(this.masterPassword, this.newEmail, kdf, kdfIterations);
request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, newKey);
const newEncKey = await this.cryptoService.remakeEncKey(newKey);

View File

@ -9,7 +9,7 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { KdfRequest } from 'jslib-common/models/request/kdfRequest';
@ -26,18 +26,23 @@ export class ChangeKdfComponent implements OnInit {
kdfOptions: any[] = [];
formPromise: Promise<any>;
constructor(private apiService: ApiService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
private messagingService: MessagingService, private userService: UserService,
private logService: LogService) {
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private cryptoService: CryptoService,
private messagingService: MessagingService,
private logService: LogService,
private stateService: StateService,
) {
this.kdfOptions = [
{ name: 'PBKDF2 SHA-256', value: KdfType.PBKDF2_SHA256 },
];
}
async ngOnInit() {
this.kdf = await this.userService.getKdf();
this.kdfIterations = await this.userService.getKdfIterations();
this.kdf = await this.stateService.getKdfType();
this.kdfIterations = await this.stateService.getKdfIterations();
}
async submit() {
@ -51,7 +56,7 @@ export class ChangeKdfComponent implements OnInit {
request.kdf = this.kdf;
request.kdfIterations = this.kdfIterations;
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null);
const email = await this.userService.getEmail();
const email = await this.stateService.getEmail();
const newKey = await this.cryptoService.makeKey(this.masterPassword, email, this.kdf, this.kdfIterations);
request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, newKey);
const newEncKey = await this.cryptoService.remakeEncKey(newKey);

View File

@ -6,12 +6,13 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import {
ChangePasswordComponent as BaseChangePasswordComponent,
@ -41,12 +42,13 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
constructor(i18nService: I18nService,
cryptoService: CryptoService, messagingService: MessagingService,
userService: UserService, passwordGenerationService: PasswordGenerationService,
stateService: StateService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService,
private folderService: FolderService, private cipherService: CipherService,
private syncService: SyncService, private apiService: ApiService, private sendService: SendService) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService);
private syncService: SyncService, private apiService: ApiService,
private sendService: SendService, private organizationService: OrganizationService) {
super(i18nService, cryptoService, messagingService, passwordGenerationService,
platformUtilsService, policyService, stateService);
}
async rotateEncKeyClicked() {
@ -206,7 +208,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
}
private async updateAllResetPasswordKeys(encKey: SymmetricCryptoKey) {
const orgs = await this.userService.getAllOrganizations();
const orgs = await this.organizationService.getAll();
for (const org of orgs) {
// If not already enrolled, skip

View File

@ -6,7 +6,7 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { AttachmentView } from 'jslib-common/models/view/attachmentView';
@ -21,11 +21,9 @@ export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponen
canAccessAttachments = true;
constructor(cipherService: CipherService, i18nService: I18nService,
cryptoService: CryptoService, userService: UserService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
logService: LogService) {
super(cipherService, i18nService, cryptoService, userService, platformUtilsService, apiService, window,
logService);
cryptoService: CryptoService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService, logService: LogService) {
super(cipherService, i18nService, cryptoService, platformUtilsService, apiService, window, logService, stateService);
}
protected async init() {

View File

@ -6,12 +6,10 @@ import {
Output,
} from '@angular/core';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { Utils } from 'jslib-common/misc/utils';
@ -31,7 +29,7 @@ export class EmergencyAccessConfirmComponent implements OnInit {
fingerprint: string;
constructor(private apiService: ApiService, private cryptoService: CryptoService,
private storageService: StorageService, private logService: LogService) { }
private stateService: StateService, private logService: LogService) { }
async ngOnInit() {
try {
@ -55,7 +53,7 @@ export class EmergencyAccessConfirmComponent implements OnInit {
}
if (this.dontAskAgain) {
await this.storageService.save(ConstantsService.autoConfirmFingerprints, true);
await this.stateService.setAutoConfirmFingerprints(true);
}
try {

View File

@ -14,7 +14,7 @@ import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { KdfType } from 'jslib-common/enums/kdfType';
import { PolicyData } from 'jslib-common/models/data/policyData';
@ -39,13 +39,26 @@ export class EmergencyAccessTakeoverComponent extends ChangePasswordComponent im
formPromise: Promise<any>;
constructor(i18nService: I18nService, cryptoService: CryptoService,
messagingService: MessagingService, userService: UserService,
constructor(
i18nService: I18nService,
cryptoService: CryptoService,
messagingService: MessagingService,
stateService: StateService,
passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService,
private apiService: ApiService, private logService: LogService) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService);
platformUtilsService: PlatformUtilsService,
policyService: PolicyService,
private apiService: ApiService,
private logService: LogService
) {
super(
i18nService,
cryptoService,
messagingService,
passwordGenerationService,
platformUtilsService,
policyService,
stateService,
);
}
async ngOnInit() {
@ -54,7 +67,7 @@ export class EmergencyAccessTakeoverComponent extends ChangePasswordComponent im
const policies = response.data.map((policyResponse: PolicyResponse) => new Policy(new PolicyData(policyResponse)));
this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions(policies);
}
}
}
async submit() {
if (!await this.strongPassword()) {

View File

@ -10,16 +10,17 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { EmergencyAccessConfirmRequest } from 'jslib-common/models/request/emergencyAccessConfirmRequest';
import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse } from 'jslib-common/models/response/emergencyAccessResponse';
import { EmergencyAccessStatusType } from 'jslib-common/enums/emergencyAccessStatusType';
import { EmergencyAccessType } from 'jslib-common/enums/emergencyAccessType';
import { Utils } from 'jslib-common/misc/utils';
import { EmergencyAccessConfirmRequest } from 'jslib-common/models/request/emergencyAccessConfirmRequest';
import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse } from 'jslib-common/models/response/emergencyAccessResponse';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { UserNamePipe } from 'jslib-angular/pipes/user-name.pipe';
@ -35,7 +36,7 @@ import { ModalService } from 'jslib-angular/services/modal.service';
})
export class EmergencyAccessComponent implements OnInit {
@ViewChild('addEdit', { read: ViewContainerRef, static: true }) addEditModalRef: ViewContainerRef;
@ViewChild('takeoverTemplate', { read: ViewContainerRef, static: true}) takeoverModalRef: ViewContainerRef;
@ViewChild('takeoverTemplate', { read: ViewContainerRef, static: true }) takeoverModalRef: ViewContainerRef;
@ViewChild('confirmTemplate', { read: ViewContainerRef, static: true }) confirmModalRef: ViewContainerRef;
canAccessPremium: boolean;
@ -46,16 +47,22 @@ export class EmergencyAccessComponent implements OnInit {
actionPromise: Promise<any>;
isOrganizationOwner: boolean;
constructor(private apiService: ApiService, private i18nService: I18nService,
private modalService: ModalService, private platformUtilsService: PlatformUtilsService,
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private modalService: ModalService,
private platformUtilsService: PlatformUtilsService,
private cryptoService: CryptoService,
private storageService: StorageService, private userService: UserService,
private messagingService: MessagingService, private userNamePipe: UserNamePipe,
private logService: LogService) { }
private messagingService: MessagingService,
private userNamePipe: UserNamePipe,
private logService: LogService,
private stateService: StateService,
private organizationService: OrganizationService,
) { }
async ngOnInit() {
this.canAccessPremium = await this.userService.canAccessPremium();
const orgs = await this.userService.getAllOrganizations();
this.canAccessPremium = await this.stateService.getCanAccessPremium();
const orgs = await this.organizationService.getAll();
this.isOrganizationOwner = orgs.some(o => o.isOwner);
this.load();
}
@ -111,7 +118,7 @@ export class EmergencyAccessComponent implements OnInit {
return;
}
const autoConfirm = await this.storageService.get<boolean>(ConstantsService.autoConfirmFingerprints);
const autoConfirm = await this.stateService.getAutoConfirmFingerPrints();
if (autoConfirm == null || !autoConfirm) {
const [modal] = await this.modalService.openViewRef(EmergencyAccessConfirmComponent, this.confirmModalRef, comp => {
comp.name = this.userNamePipe.transform(contact);

View File

@ -8,13 +8,13 @@ import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { Cipher } from 'jslib-common/models/domain/cipher';
@ -30,14 +30,14 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent {
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
userService: UserService, collectionService: CollectionService,
auditService: AuditService, stateService: StateService, collectionService: CollectionService,
totpService: TotpService, passwordGenerationService: PasswordGenerationService,
messagingService: MessagingService, eventService: EventService, policyService: PolicyService,
logService: LogService, passwordRepromptService: PasswordRepromptService) {
messagingService: MessagingService, eventService: EventService,
policyService: PolicyService, passwordRepromptService: PasswordRepromptService,
organizationService: OrganizationService, logService: LogService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, totpService, passwordGenerationService, messagingService,
eventService, policyService, passwordRepromptService, logService);
collectionService, totpService, passwordGenerationService, messagingService,
eventService, policyService, organizationService, logService, passwordRepromptService);
}
async load() {

View File

@ -14,7 +14,6 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SsoComponent } from 'jslib-angular/components/sso.component';
@ -32,11 +31,9 @@ export class LinkSsoComponent extends SsoComponent implements AfterContentInit {
apiService: ApiService, authService: AuthService,
router: Router, route: ActivatedRoute,
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
storageService: StorageService, stateService: StateService, environmentService: EnvironmentService,
logService: LogService) {
stateService: StateService, environmentService: EnvironmentService, logService: LogService) {
super(authService, router,
i18nService, route,
storageService, stateService,
i18nService, route, stateService,
platformUtilsService, apiService,
cryptoFunctionService, environmentService, passwordGenerationService, logService);

View File

@ -8,11 +8,8 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ThemeType } from 'jslib-common/enums/themeType';
import { Utils } from 'jslib-common/misc/utils';
@ -36,10 +33,13 @@ export class OptionsComponent implements OnInit {
private startingLocale: string;
private startingTheme: string;
constructor(private storageService: StorageService, private stateService: StateService,
constructor(
private stateService: StateService,
private i18nService: I18nService,
private vaultTimeoutService: VaultTimeoutService, private platformUtilsService: PlatformUtilsService,
private messagingService: MessagingService) {
private vaultTimeoutService: VaultTimeoutService,
private platformUtilsService: PlatformUtilsService,
private messagingService: MessagingService
) {
this.vaultTimeouts = [
{ name: i18nService.t('oneMinute'), value: 1 },
{ name: i18nService.t('fiveMinutes'), value: 5 },
@ -65,7 +65,7 @@ export class OptionsComponent implements OnInit {
localeOptions.splice(0, 0, { name: i18nService.t('default'), value: null });
this.localeOptions = localeOptions;
this.themeOptions = [
{ name: i18nService.t('themeLight'), value: null },
{ name: i18nService.t('themeLight'), value: ThemeType.Light },
{ name: i18nService.t('themeDark'), value: ThemeType.Dark },
{ name: i18nService.t('themeSystem'), value: ThemeType.System },
];
@ -73,12 +73,12 @@ export class OptionsComponent implements OnInit {
async ngOnInit() {
this.vaultTimeout.setValue(await this.vaultTimeoutService.getVaultTimeout());
this.vaultTimeoutAction = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
this.disableIcons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.enableGravatars = await this.storageService.get<boolean>('enableGravatars');
this.enableFullWidth = await this.storageService.get<boolean>('enableFullWidth');
this.locale = this.startingLocale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = this.startingTheme = await this.storageService.get<ThemeType>(ConstantsService.themeKey);
this.vaultTimeoutAction = await this.stateService.getVaultTimeoutAction();
this.disableIcons = await this.stateService.getDisableFavicon();
this.enableGravatars = await this.stateService.getEnableGravitars();
this.enableFullWidth = await this.stateService.getEnableFullWidth();
this.locale = await this.stateService.getLocale() ?? this.startingLocale;
this.theme = await this.stateService.getTheme() ?? this.startingTheme;
}
async submit() {
@ -88,21 +88,19 @@ export class OptionsComponent implements OnInit {
}
await this.vaultTimeoutService.setVaultTimeoutOptions(this.vaultTimeout.value, this.vaultTimeoutAction);
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableIcons);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableIcons);
await this.storageService.save('enableGravatars', this.enableGravatars);
await this.stateService.save('enableGravatars', this.enableGravatars);
await this.storageService.save('enableFullWidth', this.enableFullWidth);
await this.stateService.setDisableFavicon(this.disableIcons);
await this.stateService.setEnableGravitars(this.enableGravatars);
await this.stateService.setEnableFullWidth(this.enableFullWidth);
this.messagingService.send('setFullWidth');
if (this.theme !== this.startingTheme) {
await this.storageService.save(ConstantsService.themeKey, this.theme);
await this.stateService.setTheme(this.theme);
this.startingTheme = this.theme;
const effectiveTheme = await this.platformUtilsService.getEffectiveTheme();
const htmlEl = window.document.documentElement;
htmlEl.classList.remove('theme_' + ThemeType.Light, 'theme_' + ThemeType.Dark);
htmlEl.classList.add('theme_' + effectiveTheme);
}
await this.storageService.save(ConstantsService.localeKey, this.locale);
await this.stateService.setLocale(this.locale);
if (this.locale !== this.startingLocale) {
window.location.reload();
} else {

View File

@ -12,10 +12,10 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PaymentComponent } from './payment.component';
import { TaxInfoComponent } from './tax-info.component';
@ -73,7 +73,7 @@ export class OrganizationPlansComponent implements OnInit {
constructor(private apiService: ApiService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private cryptoService: CryptoService, private router: Router, private syncService: SyncService,
private policyService: PolicyService, private userService: UserService, private logService: LogService) {
private policyService: PolicyService, private organizationService: OrganizationService, private logService: LogService) {
this.selfHosted = platformUtilsService.isSelfHost();
}
@ -307,7 +307,7 @@ export class OrganizationPlansComponent implements OnInit {
request.billingAddressPostalCode = this.taxComponent.taxInfo.postalCode;
// Retrieve org info to backfill pub/priv key if necessary
const org = await this.userService.getOrganization(this.organizationId);
const org = await this.organizationService.get(this.organizationId);
if (!org.hasPublicAndPrivateKeys) {
const orgShareKey = await this.cryptoService.getOrgKey(this.organizationId);
const orgKeys = await this.cryptoService.makeKeyPair(orgShareKey);

View File

@ -8,10 +8,10 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { Organization } from 'jslib-common/models/domain/organization';
import { Policy } from 'jslib-common/models/domain/policy';
@ -34,7 +34,7 @@ export class OrganizationsComponent implements OnInit {
loaded: boolean = false;
actionPromise: Promise<any>;
constructor(private userService: UserService, private platformUtilsService: PlatformUtilsService,
constructor(private organizationService: OrganizationService, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private apiService: ApiService,
private syncService: SyncService,
private cryptoService: CryptoService, private policyService: PolicyService,
@ -48,7 +48,7 @@ export class OrganizationsComponent implements OnInit {
}
async load() {
const orgs = await this.userService.getAllOrganizations();
const orgs = await this.organizationService.getAll();
orgs.sort(Utils.getSortFunction(this.i18nService, 'name'));
this.organizations = orgs;
this.policies = await this.policyService.getAll(PolicyType.ResetPassword);

View File

@ -10,9 +10,9 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PaymentComponent } from './payment.component';
import { TaxInfoComponent } from './tax-info.component';
@ -37,12 +37,12 @@ export class PremiumComponent implements OnInit {
private platformUtilsService: PlatformUtilsService,
private tokenService: TokenService, private router: Router,
private messagingService: MessagingService, private syncService: SyncService,
private userService: UserService, private logService: LogService) {
private logService: LogService, private stateService: StateService) {
this.selfHosted = platformUtilsService.isSelfHost();
}
async ngOnInit() {
this.canAccessPremium = await this.userService.canAccessPremium();
this.canAccessPremium = await this.stateService.getCanAccessPremium();
const premium = await this.tokenService.getPremium();
if (premium) {
this.router.navigate(['/settings/subscription']);

View File

@ -9,7 +9,7 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { KeyConnectorService } from 'jslib-common/abstractions/keyConnector.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UpdateProfileRequest } from 'jslib-common/models/request/updateProfileRequest';
@ -27,15 +27,20 @@ export class ProfileComponent implements OnInit {
formPromise: Promise<any>;
constructor(private apiService: ApiService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private userService: UserService,
private cryptoService: CryptoService, private logService: LogService,
private keyConnectorService: KeyConnectorService) { }
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private cryptoService: CryptoService,
private logService: LogService,
private keyConnectorService: KeyConnectorService,
private stateService: StateService,
) { }
async ngOnInit() {
this.profile = await this.apiService.getProfile();
this.loading = false;
const fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId());
const fingerprint = await this.cryptoService.getFingerprint(await this.stateService.getUserId());
if (fingerprint != null) {
this.fingerprint = fingerprint.join('-');
}

View File

@ -6,9 +6,9 @@ import {
} from '@angular/core';
import { BroadcasterService } from 'jslib-common/abstractions/broadcaster.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
const BroadcasterSubscriptionId = 'SettingsComponent';
@ -23,7 +23,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
constructor(private tokenService: TokenService, private broadcasterService: BroadcasterService,
private ngZone: NgZone, private platformUtilsService: PlatformUtilsService,
private userService: UserService) { }
private organizationService: OrganizationService) { }
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
@ -47,6 +47,6 @@ export class SettingsComponent implements OnInit, OnDestroy {
async load() {
this.premium = await this.tokenService.getPremium();
this.hasFamilySponsorshipAvailable = await this.userService.canManageSponsorships();
this.hasFamilySponsorshipAvailable = await this.organizationService.canManageSponsorships();
}
}

View File

@ -4,9 +4,9 @@ import {
} from '@angular/core';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PlanSponsorshipType } from 'jslib-common/enums/planSponsorshipType';
import { Organization } from 'jslib-common/models/domain/organization';
@ -26,9 +26,13 @@ export class SponsoredFamiliesComponent implements OnInit {
// Conditional display properties
formPromise: Promise<any>;
constructor(private userService: UserService, private apiService: ApiService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
private syncService: SyncService) { }
constructor(
private apiService: ApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private syncService: SyncService,
private organizationService: OrganizationService,
) { }
async ngOnInit() {
await this.load();
@ -58,7 +62,7 @@ export class SponsoredFamiliesComponent implements OnInit {
await this.syncService.fullSync(true);
}
const allOrgs = await this.userService.getAllOrganizations();
const allOrgs = await this.organizationService.getAll();
this.availableSponsorshipOrgs = allOrgs.filter(org => org.familySponsorshipAvailable);
this.activeSponsorshipOrgs = allOrgs.filter(org => org.familySponsorshipFriendlyName !== null);

View File

@ -8,7 +8,7 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
import { UpdateTwoFactorAuthenticatorRequest } from 'jslib-common/models/request/updateTwoFactorAuthenticatorRequest';
@ -30,11 +30,21 @@ export class TwoFactorAuthenticatorComponent extends TwoFactorBaseComponent impl
private qrScript: HTMLScriptElement;
constructor(apiService: ApiService, i18nService: I18nService,
constructor(
apiService: ApiService,
i18nService: I18nService,
userVerificationService: UserVerificationService,
platformUtilsService: PlatformUtilsService, logService: LogService,
private userService: UserService) {
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
platformUtilsService: PlatformUtilsService,
logService: LogService,
private stateService: StateService
) {
super(
apiService,
i18nService,
platformUtilsService,
logService,
userVerificationService
);
this.qrScript = window.document.createElement('script');
this.qrScript.src = 'scripts/qrious.min.js';
this.qrScript.async = true;
@ -77,7 +87,7 @@ export class TwoFactorAuthenticatorComponent extends TwoFactorBaseComponent impl
this.token = null;
this.enabled = response.enabled;
this.key = response.key;
const email = await this.userService.getEmail();
const email = await this.stateService.getEmail();
window.setTimeout(() => {
const qr = new (window as any).QRious({
element: document.getElementById('qr'),

View File

@ -4,7 +4,7 @@ import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
import { TwoFactorEmailRequest } from 'jslib-common/models/request/twoFactorEmailRequest';
@ -27,11 +27,21 @@ export class TwoFactorEmailComponent extends TwoFactorBaseComponent {
formPromise: Promise<any>;
emailPromise: Promise<any>;
constructor(apiService: ApiService, i18nService: I18nService,
constructor(
apiService: ApiService,
i18nService: I18nService,
platformUtilsService: PlatformUtilsService,
logService: LogService, userVerificationService: UserVerificationService,
private userService: UserService) {
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
logService: LogService,
userVerificationService: UserVerificationService,
private stateService: StateService,
) {
super(
apiService,
i18nService,
platformUtilsService,
logService,
userVerificationService
);
}
auth(authResponse: any) {
@ -76,7 +86,7 @@ export class TwoFactorEmailComponent extends TwoFactorBaseComponent {
this.email = response.email;
this.enabled = response.enabled;
if (!this.enabled && (this.email == null || this.email === '')) {
this.email = await this.userService.getEmail();
this.email = await this.stateService.getEmail();
}
}
}

View File

@ -9,7 +9,7 @@ import {
import { ApiService } from 'jslib-common/abstractions/api.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { TwoFactorProviders } from 'jslib-common/services/auth.service';
@ -46,12 +46,12 @@ export class TwoFactorSetupComponent implements OnInit {
loading = true;
modal: ModalRef;
constructor(protected apiService: ApiService, protected userService: UserService,
protected modalService: ModalService, protected messagingService: MessagingService,
protected policyService: PolicyService) { }
constructor(protected apiService: ApiService, protected modalService: ModalService,
protected messagingService: MessagingService, protected policyService: PolicyService,
private stateService: StateService) { }
async ngOnInit() {
this.canAccessPremium = await this.userService.canAccessPremium();
this.canAccessPremium = await this.stateService.getCanAccessPremium();
for (const key in TwoFactorProviders) {
if (!TwoFactorProviders.hasOwnProperty(key)) {

View File

@ -4,7 +4,7 @@ import {
} from '@angular/core';
import { AuditService } from 'jslib-common/abstractions/audit.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { BreachAccountResponse } from 'jslib-common/models/response/breachAccountResponse';
@Component({
@ -18,10 +18,10 @@ export class BreachReportComponent implements OnInit {
breachedAccounts: BreachAccountResponse[] = [];
formPromise: Promise<BreachAccountResponse[]>;
constructor(private auditService: AuditService, private userService: UserService) { }
constructor(private auditService: AuditService, private stateService: StateService) { }
async ngOnInit() {
this.username = await this.userService.getEmail();
this.username = await this.stateService.getEmail();
}
async submit() {

View File

@ -11,11 +11,11 @@ import { Organization } from 'jslib-common/models/domain/organization';
import { AddEditComponent as OrgAddEditComponent } from '../organizations/vault/add-edit.component';
import { AddEditComponent } from '../vault/add-edit.component';
import { CipherRepromptType } from 'jslib-common/enums/cipherRepromptType';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { CipherRepromptType } from 'jslib-common/enums/cipherRepromptType';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -28,9 +28,9 @@ export class CipherReportComponent {
ciphers: CipherView[] = [];
organization: Organization;
constructor(private modalService: ModalService, protected userService: UserService,
protected messagingService: MessagingService, protected passwordRepromptService: PasswordRepromptService,
public requiresPaid: boolean) { }
constructor(private modalService: ModalService, protected messagingService: MessagingService,
public requiresPaid: boolean, private stateService: StateService,
protected passwordRepromptService: PasswordRepromptService) { }
async load() {
this.loading = true;
@ -80,7 +80,7 @@ export class CipherReportComponent {
return false;
}
} else {
const accessPremium = await this.userService.canAccessPremium();
const accessPremium = await this.stateService.getCanAccessPremium();
if (this.requiresPaid && !accessPremium) {
this.messagingService.send('premiumRequired');
this.loading = false;

View File

@ -7,7 +7,7 @@ import { AuditService } from 'jslib-common/abstractions/audit.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -26,8 +26,8 @@ export class ExposedPasswordsReportComponent extends CipherReportComponent imple
constructor(protected cipherService: CipherService, protected auditService: AuditService,
modalService: ModalService, messagingService: MessagingService,
userService: UserService, passwordRepromptService: PasswordRepromptService) {
super(modalService, userService, messagingService, passwordRepromptService, true);
stateService: StateService, passwordRepromptService: PasswordRepromptService) {
super(modalService, messagingService, true, stateService, passwordRepromptService);
}
ngOnInit() {

View File

@ -7,7 +7,7 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -28,9 +28,9 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl
cipherDocs = new Map<string, string>();
constructor(protected cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService, private logService: LogService,
messagingService: MessagingService, stateService: StateService, private logService: LogService,
passwordRepromptService: PasswordRepromptService) {
super(modalService, userService, messagingService, passwordRepromptService, true);
super(modalService, messagingService, true, stateService, passwordRepromptService);
}
async ngOnInit() {

View File

@ -6,7 +6,7 @@ import {
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -24,9 +24,9 @@ export class ReusedPasswordsReportComponent extends CipherReportComponent implem
passwordUseMap: Map<string, number>;
constructor(protected cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService,
messagingService: MessagingService, stateService: StateService,
passwordRepromptService: PasswordRepromptService) {
super(modalService, userService, messagingService, passwordRepromptService, true);
super(modalService, messagingService, true, stateService, passwordRepromptService);
}
async ngOnInit() {

View File

@ -4,7 +4,7 @@ import {
} from '@angular/core';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
@Component({
selector: 'app-tools',
@ -13,10 +13,10 @@ import { UserService } from 'jslib-common/abstractions/user.service';
export class ToolsComponent implements OnInit {
canAccessPremium = false;
constructor(private userService: UserService, private messagingService: MessagingService) { }
constructor(private stateService: StateService, private messagingService: MessagingService) { }
async ngOnInit() {
this.canAccessPremium = await this.userService.canAccessPremium();
this.canAccessPremium = await this.stateService.getCanAccessPremium();
}
premiumRequired() {

View File

@ -6,7 +6,7 @@ import {
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -22,8 +22,9 @@ import { CipherReportComponent } from './cipher-report.component';
})
export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit {
constructor(protected cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService, passwordRepromptService: PasswordRepromptService) {
super(modalService, userService, messagingService, passwordRepromptService, true);
messagingService: MessagingService, stateService: StateService,
passwordRepromptService: PasswordRepromptService) {
super(modalService, messagingService, true, stateService, passwordRepromptService);
}
async ngOnInit() {

View File

@ -7,7 +7,7 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -28,9 +28,9 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
private passwordStrengthCache = new Map<string, number>();
constructor(protected cipherService: CipherService, protected passwordGenerationService: PasswordGenerationService,
modalService: ModalService, messagingService: MessagingService, userService: UserService,
passwordRepromptService: PasswordRepromptService) {
super(modalService, userService, messagingService, passwordRepromptService, true);
modalService: ModalService, messagingService: MessagingService,
stateService: StateService, passwordRepromptService: PasswordRepromptService) {
super(modalService, messagingService, true, stateService, passwordRepromptService);
}
async ngOnInit() {

View File

@ -11,13 +11,13 @@ import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { AddEditComponent as BaseAddEditComponent } from 'jslib-angular/components/add-edit.component';
import { LoginUriView } from 'jslib-common/models/view/loginUriView';
@ -43,14 +43,12 @@ export class AddEditComponent extends BaseAddEditComponent {
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
userService: UserService, collectionService: CollectionService,
protected totpService: TotpService, protected passwordGenerationService: PasswordGenerationService,
protected messagingService: MessagingService, eventService: EventService,
protected policyService: PolicyService, passwordRepromptService: PasswordRepromptService,
logService: LogService) {
collectionService: CollectionService, protected totpService: TotpService,
protected passwordGenerationService: PasswordGenerationService, protected messagingService: MessagingService,
eventService: EventService, protected policyService: PolicyService, organizationService: OrganizationService, logService: LogService,
passwordRepromptService: PasswordRepromptService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, messagingService, eventService, policyService, passwordRepromptService,
logService);
collectionService, messagingService, eventService, policyService, logService, passwordRepromptService, organizationService);
}
async ngOnInit() {
@ -60,7 +58,7 @@ export class AddEditComponent extends BaseAddEditComponent {
this.hasPasswordHistory = this.cipher.hasPasswordHistory;
this.cleanUp();
this.canAccessPremium = await this.userService.canAccessPremium();
this.canAccessPremium = await this.stateService.getCanAccessPremium();
if (this.cipher.type === CipherType.Login && this.cipher.login.totp &&
(this.cipher.organizationUseTotp || this.canAccessPremium)) {
await this.totpUpdateCode();

View File

@ -6,7 +6,7 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { AttachmentView } from 'jslib-common/models/view/attachmentView';
@ -20,11 +20,10 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
viewOnly = false;
constructor(cipherService: CipherService, i18nService: I18nService,
cryptoService: CryptoService, userService: UserService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
logService: LogService) {
super(cipherService, i18nService, cryptoService, userService, platformUtilsService, apiService, window,
logService);
cryptoService: CryptoService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService, logService: LogService) {
super(cipherService, i18nService, cryptoService, platformUtilsService, apiService, window, logService,
stateService);
}
protected async reupload(attachment: AttachmentView) {

View File

@ -10,8 +10,8 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CollectionView } from 'jslib-common/models/view/collectionView';
@ -37,14 +37,14 @@ export class BulkShareComponent implements OnInit {
constructor(private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private collectionService: CollectionService,
private userService: UserService, private logService: LogService) { }
private organizationService: OrganizationService, private logService: LogService) { }
async ngOnInit() {
this.shareableCiphers = this.ciphers.filter(c => !c.hasOldAttachments && c.organizationId == null);
this.nonShareableCount = this.ciphers.length - this.shareableCiphers.length;
const allCollections = await this.collectionService.getAllDecrypted();
this.writeableCollections = allCollections.filter(c => !c.readOnly);
this.organizations = await this.userService.getAllOrganizations();
this.organizations = await this.organizationService.getAll();
if (this.organizationId == null && this.organizations.length > 0) {
this.organizationId = this.organizations[0].id;
}

View File

@ -13,8 +13,8 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { CiphersComponent as BaseCiphersComponent } from 'jslib-angular/components/ciphers.component';
@ -50,13 +50,13 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
constructor(searchService: SearchService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected cipherService: CipherService, protected eventService: EventService,
protected totpService: TotpService, protected userService: UserService,
protected totpService: TotpService, protected stateService: StateService,
protected passwordRepromptService: PasswordRepromptService, private logService: LogService) {
super(searchService);
}
async ngOnInit() {
this.userHasPremiumAccess = await this.userService.canAccessPremium();
this.userHasPremiumAccess = await this.stateService.getCanAccessPremium();
}
ngOnDestroy() {

View File

@ -6,8 +6,7 @@ import {
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { GroupingsComponent as BaseGroupingsComponent } from 'jslib-angular/components/groupings.component';
@ -22,8 +21,8 @@ export class GroupingsComponent extends BaseGroupingsComponent {
searchPlaceholder: string = null;
constructor(collectionService: CollectionService, folderService: FolderService,
storageService: StorageService, userService: UserService) {
super(collectionService, folderService, storageService, userService);
stateService: StateService) {
super(collectionService, folderService, stateService);
}
searchTextChanged() {

View File

@ -6,8 +6,8 @@ import {
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { CollectionView } from 'jslib-common/models/view/collectionView';
@ -20,10 +20,10 @@ import { LogService } from 'jslib-common/abstractions/log.service';
})
export class ShareComponent extends BaseShareComponent implements OnDestroy {
constructor(collectionService: CollectionService, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, userService: UserService,
cipherService: CipherService, logService: LogService) {
super(collectionService, platformUtilsService, i18nService, userService, cipherService,
logService);
i18nService: I18nService, cipherService: CipherService,
organizationService: OrganizationService, logService: LogService) {
super(collectionService, platformUtilsService, i18nService, cipherService,
logService, organizationService);
}
ngOnDestroy() {

View File

@ -32,10 +32,12 @@ import { BroadcasterService } from 'jslib-common/abstractions/broadcaster.servic
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@ -74,9 +76,10 @@ export class VaultComponent implements OnInit, OnDestroy {
private router: Router, private changeDetectorRef: ChangeDetectorRef,
private i18nService: I18nService, private modalService: ModalService,
private tokenService: TokenService, private cryptoService: CryptoService,
private messagingService: MessagingService, private userService: UserService,
private platformUtilsService: PlatformUtilsService, private broadcasterService: BroadcasterService,
private ngZone: NgZone) { }
private messagingService: MessagingService, private platformUtilsService: PlatformUtilsService,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
private stateService: StateService, private organizationService: OrganizationService,
private providerService: ProviderService) { }
async ngOnInit() {
this.showVerifyEmail = !(await this.tokenService.getEmailVerified());
@ -88,20 +91,20 @@ export class VaultComponent implements OnInit, OnDestroy {
this.route.queryParams.pipe(first()).subscribe(async params => {
await this.syncService.fullSync(false);
this.showUpdateKey = !(await this.cryptoService.hasEncKey());
const canAccessPremium = await this.userService.canAccessPremium();
const canAccessPremium = await this.stateService.getCanAccessPremium();
this.showPremiumCallout = !this.showVerifyEmail && !canAccessPremium &&
!this.platformUtilsService.isSelfHost();
this.showProviders = (await this.userService.getAllProviders()).length > 0;
this.showProviders = (await this.providerService.getAll()).length > 0;
const allOrgs = await this.userService.getAllOrganizations();
const allOrgs = await this.organizationService.getAll();
this.showRedeemSponsorship = allOrgs.some(o => o.familySponsorshipAvailable) && !allOrgs.some(o => o.familySponsorshipFriendlyName != null);
await Promise.all([
this.groupingsComponent.load(),
this.organizationsComponent.load(),
]);
this.showUpdateKey = !(await this.cryptoService.hasEncKey());
if (params == null) {
this.groupingsComponent.selectedAll = true;
@ -215,12 +218,12 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async editCipherAttachments(cipher: CipherView) {
const canAccessPremium = await this.userService.canAccessPremium();
const canAccessPremium = await this.stateService.getCanAccessPremium();
if (cipher.organizationId == null && !canAccessPremium) {
this.messagingService.send('premiumRequired');
return;
} else if (cipher.organizationId != null) {
const org = await this.userService.getOrganization(cipher.organizationId);
const org = await this.organizationService.get(cipher.organizationId);
if (org != null && (org.maxStorageGb == null || org.maxStorageGb === 0)) {
this.messagingService.send('upgradeOrganization', { organizationId: cipher.organizationId });
return;

View File

@ -83,7 +83,7 @@ function parseParametersV2() {
btnText: string;
btnReturnText: string;
callbackUri?: string;
mobile?: boolean
mobile?: boolean;
} = null;
try {
dataObj = JSON.parse(b64Decode(getQsParam('data')));

View File

@ -1,45 +1,40 @@
import { Injectable } from '@angular/core';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { HtmlStorageLocation } from 'jslib-common/enums/htmlStorageLocation';
import { GlobalState } from 'jslib-common/models/domain/globalState';
import { State } from 'jslib-common/models/domain/state';
import { StorageOptions } from 'jslib-common/models/domain/storageOptions';
@Injectable()
export class HtmlStorageService implements StorageService {
private localStorageKeys = new Set(['appId', 'anonymousAppId', 'rememberedEmail', 'passwordGenerationOptions',
ConstantsService.disableFaviconKey, 'rememberEmail', 'enableGravatars', 'enableFullWidth',
ConstantsService.localeKey, ConstantsService.autoConfirmFingerprints,
ConstantsService.vaultTimeoutKey, ConstantsService.vaultTimeoutActionKey, ConstantsService.ssoCodeVerifierKey,
ConstantsService.ssoStateKey, 'ssoOrgIdentifier', ConstantsService.themeKey]);
private localStorageStartsWithKeys = ['twoFactorToken_', ConstantsService.collapsedGroupingsKey + '_'];
private memoryStorageStartsWithKeys = ['ciphers_', 'folders_', 'collections_', 'settings_', 'lastSync_'];
private memoryStorage = new Map<string, string>();
constructor(private platformUtilsService: PlatformUtilsService) { }
async init() {
// LockOption -> VaultTimeout (uses the same legacy string value for backwards compat)
const vaultTimeout = await this.get<number>(ConstantsService.vaultTimeoutKey);
if (vaultTimeout == null && !this.platformUtilsService.isDev()) {
await this.save(ConstantsService.vaultTimeoutKey, 15);
}
// Default Action to lock
const vaultTimeoutAction = await this.get<string>(ConstantsService.vaultTimeoutActionKey);
if (vaultTimeoutAction == null) {
await this.save(ConstantsService.vaultTimeoutActionKey, 'lock');
}
get defaultOptions(): StorageOptions {
return { htmlStorageLocation: HtmlStorageLocation.Session };
}
get<T>(key: string): Promise<T> {
async init() {
const state = await this.get<State>('state', { htmlStorageLocation: HtmlStorageLocation.Local }) ?? new State();
state.globals = state.globals ?? new GlobalState();
state.globals.vaultTimeout = state.globals.vaultTimeout ?? 15;
state.globals.vaultTimeoutAction = state.globals.vaultTimeoutAction ?? 'lock';
await this.save('state', state, { htmlStorageLocation: HtmlStorageLocation.Local });
}
get<T>(key: string, options: StorageOptions = this.defaultOptions): Promise<T> {
let json: string = null;
if (this.isLocalStorage(key)) {
json = window.localStorage.getItem(key);
} else if (this.isMemoryStorage(key)) {
json = this.memoryStorage.get(key);
} else {
json = window.sessionStorage.getItem(key);
switch (options.htmlStorageLocation) {
case HtmlStorageLocation.Local:
json = window.localStorage.getItem(key);
break;
case HtmlStorageLocation.Session:
default:
json = window.sessionStorage.getItem(key);
break;
}
if (json != null) {
const obj = JSON.parse(json);
return Promise.resolve(obj as T);
@ -47,13 +42,13 @@ export class HtmlStorageService implements StorageService {
return Promise.resolve(null);
}
async has(key: string): Promise<boolean> {
return await this.get(key) != null;
async has(key: string, options: StorageOptions = this.defaultOptions): Promise<boolean> {
return await this.get(key, options) != null;
}
save(key: string, obj: any): Promise<any> {
save(key: string, obj: any, options: StorageOptions = this.defaultOptions): Promise<any> {
if (obj == null) {
return this.remove(key);
return this.remove(key, options);
}
if (obj instanceof Set) {
@ -61,45 +56,28 @@ export class HtmlStorageService implements StorageService {
}
const json = JSON.stringify(obj);
if (this.isLocalStorage(key)) {
window.localStorage.setItem(key, json);
} else if (this.isMemoryStorage(key)) {
this.memoryStorage.set(key, json);
} else {
window.sessionStorage.setItem(key, json);
switch (options.htmlStorageLocation) {
case HtmlStorageLocation.Local:
window.localStorage.setItem(key, json);
break;
case HtmlStorageLocation.Session:
default:
window.sessionStorage.setItem(key, json);
break;
}
return Promise.resolve();
}
remove(key: string): Promise<any> {
if (this.isLocalStorage(key)) {
window.localStorage.removeItem(key);
} else if (this.isMemoryStorage(key)) {
this.memoryStorage.delete(key);
} else {
window.sessionStorage.removeItem(key);
remove(key: string, options: StorageOptions = this.defaultOptions): Promise<any> {
switch (options.htmlStorageLocation) {
case HtmlStorageLocation.Local:
window.localStorage.removeItem(key);
break;
case HtmlStorageLocation.Session:
default:
window.sessionStorage.removeItem(key);
break;
}
return Promise.resolve();
}
private isLocalStorage(key: string): boolean {
if (this.localStorageKeys.has(key)) {
return true;
}
for (const swKey of this.localStorageStartsWithKeys) {
if (key.startsWith(swKey)) {
return true;
}
}
return false;
}
private isMemoryStorage(key: string): boolean {
for (const swKey of this.memoryStorageStartsWithKeys) {
if (key.startsWith(swKey)) {
return true;
}
}
return false;
}
}

View File

@ -7,9 +7,7 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { StateService } from 'jslib-common/abstractions/state.service';
export class WebPlatformUtilsService implements PlatformUtilsService {
identityClientId: string = 'web';
@ -18,7 +16,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
private prefersColorSchemeDark = window.matchMedia('(prefers-color-scheme: dark)');
constructor(private i18nService: I18nService, private messagingService: MessagingService,
private logService: LogService, private storageService: () => StorageService) { }
private logService: LogService, private stateService: StateService) { }
getDevice(): DeviceType {
if (this.browserCache != null) {
@ -293,7 +291,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
}
async getEffectiveTheme(): Promise<ThemeType.Light | ThemeType.Dark> {
const theme = await this.storageService().get<ThemeType>(ConstantsService.themeKey);
const theme = await this.stateService.getTheme();
if (theme === ThemeType.Dark) {
return ThemeType.Dark;
} else if (theme === ThemeType.System) {

Some files were not shown because too many files have changed in this diff Show More