mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-10 06:08:34 +02:00
e17a49acd5
* created and applied link-sso component * implemented linking existing user to sso * removed an unused import * created and applied link-sso component * implemented linking existing user to sso * removed an unused import * merge * added a token to the sso linking flow * [jslib] Update (5d874d0
->6ab444a
) (#618) * Update jslib (5d874d0
->6ab444a
) * Update dependency flows * created and applied link-sso component * implemented linking existing user to sso * removed an unused import * merge * added a token to the sso linking flow * implemented linking existing user to sso * removed an unused import * account for some variable shakeup in jslib for link sso * updated jslib * updated jslib * still trying to fix jslib * finally, really, truly updated jslib Co-authored-by: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com>
88 lines
3.0 KiB
TypeScript
88 lines
3.0 KiB
TypeScript
import {
|
|
Component,
|
|
Input,
|
|
OnInit,
|
|
} from '@angular/core';
|
|
|
|
import { ToasterService } from 'angular2-toaster';
|
|
import { Angulartics2 } from 'angulartics2';
|
|
|
|
import { ApiService } from 'jslib/abstractions/api.service';
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
|
import { SyncService } from 'jslib/abstractions/sync.service';
|
|
import { UserService } from 'jslib/abstractions/user.service';
|
|
|
|
import { Organization } from 'jslib/models/domain/organization';
|
|
|
|
import { Utils } from 'jslib/misc/utils';
|
|
|
|
@Component({
|
|
selector: 'app-organizations',
|
|
templateUrl: 'organizations.component.html',
|
|
})
|
|
export class OrganizationsComponent implements OnInit {
|
|
@Input() vault = false;
|
|
|
|
organizations: Organization[];
|
|
loaded: boolean = false;
|
|
actionPromise: Promise<any>;
|
|
|
|
constructor(private userService: UserService, private platformUtilsService: PlatformUtilsService,
|
|
private i18nService: I18nService, private apiService: ApiService,
|
|
private analytics: Angulartics2, private toasterService: ToasterService,
|
|
private syncService: SyncService) { }
|
|
|
|
async ngOnInit() {
|
|
if (!this.vault) {
|
|
await this.syncService.fullSync(true);
|
|
await this.load();
|
|
}
|
|
}
|
|
|
|
async load() {
|
|
const orgs = await this.userService.getAllOrganizations();
|
|
orgs.sort(Utils.getSortFunction(this.i18nService, 'name'));
|
|
this.organizations = orgs;
|
|
this.loaded = true;
|
|
}
|
|
|
|
async unlinkSso(org: Organization) {
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
|
'Are you sure you want to unlink SSO for this organization?', org.name,
|
|
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
|
if (!confirmed) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
this.actionPromise = this.apiService.deleteSsoUser(org.id).then(() => {
|
|
return this.syncService.fullSync(true);
|
|
});
|
|
await this.actionPromise;
|
|
this.analytics.eventTrack.next({ action: 'Unlinked SSO' });
|
|
this.toasterService.popAsync('success', null, 'Unlinked SSO');
|
|
await this.load();
|
|
} catch { }
|
|
}
|
|
|
|
async leave(org: Organization) {
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
|
this.i18nService.t('leaveOrganizationConfirmation'), org.name,
|
|
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
|
if (!confirmed) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
this.actionPromise = this.apiService.postLeaveOrganization(org.id).then(() => {
|
|
return this.syncService.fullSync(true);
|
|
});
|
|
await this.actionPromise;
|
|
this.analytics.eventTrack.next({ action: 'Left Organization' });
|
|
this.toasterService.popAsync('success', null, this.i18nService.t('leftOrganization'));
|
|
await this.load();
|
|
} catch { }
|
|
}
|
|
}
|