1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-02 08:33:43 +00:00

[Reset Password] Enrollment actions (#900)

* [Reset Password] Enrollment actions

* Update jslib (0951424 -> f4f00b1)

* Added status icon
This commit is contained in:
Vincent Salucci
2021-04-05 09:48:46 -05:00
committed by GitHub
parent 0aee3b7370
commit 32e9124b9c
5 changed files with 88 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { ApiService } from 'jslib/abstractions/api.service';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { SyncService } from 'jslib/abstractions/sync.service';
@@ -17,6 +18,8 @@ import { Organization } from 'jslib/models/domain/organization';
import { Utils } from 'jslib/misc/utils';
import { OrganizationUserResetPasswordEnrollmentRequest } from 'jslib/models/request/organizationUserResetPasswordEnrollmentRequest';
@Component({
selector: 'app-organizations',
templateUrl: 'organizations.component.html',
@@ -31,7 +34,7 @@ export class OrganizationsComponent implements OnInit {
constructor(private userService: UserService, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private apiService: ApiService,
private analytics: Angulartics2, private toasterService: ToasterService,
private syncService: SyncService) { }
private syncService: SyncService, private cryptoService: CryptoService) { }
async ngOnInit() {
if (!this.vault) {
@@ -84,4 +87,32 @@ export class OrganizationsComponent implements OnInit {
await this.load();
} catch { }
}
async toggleResetPasswordEnrollment(org: Organization) {
// Set variables
let keyString: string = null;
let toastStringRef = 'withdrawPasswordResetSuccess';
// Enroll - encrpyt user's encKey.key with organization key
if (!org.isResetPasswordEnrolled) {
const encKey = await this.cryptoService.getEncKey();
const orgSymKey = await this.cryptoService.getOrgKey(org.id);
const encryptedKey = await this.cryptoService.encrypt(encKey.key, orgSymKey);
keyString = encryptedKey.encryptedString;
toastStringRef = 'enrollPasswordResetSuccess';
}
// Create/Execute request
try {
const request = new OrganizationUserResetPasswordEnrollmentRequest();
request.resetPasswordKey = keyString;
this.actionPromise = this.apiService.putOrganizationUserResetPasswordEnrollment(org.id, org.userId, request)
.then(() => {
return this.syncService.fullSync(true);
});
await this.actionPromise;
this.platformUtilsService.showToast('success', null, this.i18nService.t(toastStringRef));
await this.load();
} catch { }
}
}