mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-14 01:01:31 +01:00
[Reset Password] Enrollment actions (#900)
* [Reset Password] Enrollment actions * Update jslib (0951424
->f4f00b1
) * Added status icon
This commit is contained in:
parent
0aee3b7370
commit
32e9124b9c
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 5c734747a96e3cef62ff5153d8da116559395869
|
||||
Subproject commit f4f00b1eb290eb57ee3a93043e8a44685ee51c59
|
@ -155,6 +155,13 @@ export class EventService {
|
||||
break;
|
||||
case EventType.OrganizationUser_UnlinkedSso:
|
||||
msg = this.i18nService.t('unlinkedSsoUser', this.formatOrgUserId(ev));
|
||||
break;
|
||||
case EventType.OrganizationUser_ResetPassword_Enroll:
|
||||
msg = this.i18nService.t('eventEnrollPasswordReset', this.formatOrgUserId(ev));
|
||||
break;
|
||||
case EventType.OrganizationUser_ResetPassword_Withdraw:
|
||||
msg = this.i18nService.t('eventWithdrawPasswordReset', this.formatOrgUserId(ev));
|
||||
break;
|
||||
// Org
|
||||
case EventType.Organization_Updated:
|
||||
msg = this.i18nService.t('editedOrgSettings');
|
||||
|
@ -65,6 +65,11 @@
|
||||
title="{{'organizationIsDisabled' | i18n}}" aria-hidden="true"></i>
|
||||
<span class="sr-only">{{'organizationIsDisabled' | i18n}}</span>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="o.isResetPasswordEnrolled">
|
||||
<i class="fa fa-key" appStopProp title="{{'enrolledPasswordReset' | i18n}}"
|
||||
aria-hidden="true"></i>
|
||||
<span class="sr-only">{{'enrolledPasswordReset' | i18n}}</span>
|
||||
</ng-container>
|
||||
</td>
|
||||
<td class="table-list-options">
|
||||
<div class="dropdown" appListDropdown>
|
||||
@ -74,6 +79,16 @@
|
||||
<i class="fa fa-cog fa-lg" aria-hidden="true"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a *ngIf="!o.isResetPasswordEnrolled" class="dropdown-item" href="#" appStopClick
|
||||
(click)="toggleResetPasswordEnrollment(o)">
|
||||
<i class="fa fa-fw fa-key" aria-hidden="true"></i>
|
||||
{{'enrollPasswordReset' | i18n}}
|
||||
</a>
|
||||
<a *ngIf="o.isResetPasswordEnrolled" class="dropdown-item" href="#" appStopClick
|
||||
(click)="toggleResetPasswordEnrollment(o)">
|
||||
<i class="fa fa-fw fa-undo" aria-hidden="true"></i>
|
||||
{{'withdrawPasswordReset' | i18n}}
|
||||
</a>
|
||||
<ng-container *ngIf="o.useSso && o.identifier">
|
||||
<a *ngIf="o.ssoBound; else linkSso" class="dropdown-item" href="#" appStopClick
|
||||
(click)="unlinkSso(o)">
|
||||
|
@ -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 { }
|
||||
}
|
||||
}
|
||||
|
@ -3833,5 +3833,38 @@
|
||||
},
|
||||
"hintEqualsPassword": {
|
||||
"message": "Your password hint cannot be the same as your password."
|
||||
},
|
||||
"enrollPasswordReset": {
|
||||
"message": "Enroll in Password Reset"
|
||||
},
|
||||
"enrolledPasswordReset": {
|
||||
"message": "Enrolled in Password Reset"
|
||||
},
|
||||
"withdrawPasswordReset": {
|
||||
"message": "Withdraw from Password Reset"
|
||||
},
|
||||
"enrollPasswordResetSuccess": {
|
||||
"message": "Enrollment success!"
|
||||
},
|
||||
"withdrawPasswordResetSuccess": {
|
||||
"message": "Withdrawal success!"
|
||||
},
|
||||
"eventEnrollPasswordReset": {
|
||||
"message": "User $ID$ enrolled in password reset assistance.",
|
||||
"placeholders": {
|
||||
"id": {
|
||||
"content": "$1",
|
||||
"example": "John Smith"
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventWithdrawPasswordReset": {
|
||||
"message": "User $ID$ withdrew from password reset assistance.",
|
||||
"placeholders": {
|
||||
"id": {
|
||||
"content": "$1",
|
||||
"example": "John Smith"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user