[EC-338] Update SCIM code naming conventions (revoked/restore) (#3160)

This commit is contained in:
Thomas Rittson 2022-07-25 10:47:56 +10:00 committed by GitHub
parent 8694227b92
commit 0f44789d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 87 additions and 95 deletions

View File

@ -55,9 +55,9 @@ export abstract class BasePeopleComponent<
: 0;
}
get deactivatedCount() {
return this.statusMap.has(this.userStatusType.Deactivated)
? this.statusMap.get(this.userStatusType.Deactivated).length
get revokedCount() {
return this.statusMap.has(this.userStatusType.Revoked)
? this.statusMap.get(this.userStatusType.Revoked).length
: 0;
}
@ -112,8 +112,8 @@ export abstract class BasePeopleComponent<
abstract edit(user: UserType): void;
abstract getUsers(): Promise<ListResponse<UserType>>;
abstract deleteUser(id: string): Promise<any>;
abstract deactivateUser(id: string): Promise<any>;
abstract activateUser(id: string): Promise<any>;
abstract revokeUser(id: string): Promise<any>;
abstract restoreUser(id: string): Promise<any>;
abstract reinviteUser(id: string): Promise<any>;
abstract confirmUser(user: UserType, publicKey: Uint8Array): Promise<any>;
@ -133,7 +133,7 @@ export abstract class BasePeopleComponent<
} else {
this.statusMap.get(u.status).push(u);
}
if (u.status !== this.userStatusType.Deactivated) {
if (u.status !== this.userStatusType.Revoked) {
this.activeUsers.push(u);
}
});
@ -235,9 +235,9 @@ export abstract class BasePeopleComponent<
this.actionPromise = null;
}
async deactivate(user: UserType) {
async revoke(user: UserType) {
const confirmed = await this.platformUtilsService.showDialog(
this.deactivateWarningMessage(),
this.revokeWarningMessage(),
this.i18nService.t("revokeUserId", this.userNamePipe.transform(user)),
this.i18nService.t("revokeAccess"),
this.i18nService.t("cancel"),
@ -248,7 +248,7 @@ export abstract class BasePeopleComponent<
return false;
}
this.actionPromise = this.deactivateUser(user.id);
this.actionPromise = this.revokeUser(user.id);
try {
await this.actionPromise;
this.platformUtilsService.showToast(
@ -263,8 +263,8 @@ export abstract class BasePeopleComponent<
this.actionPromise = null;
}
async activate(user: UserType) {
this.actionPromise = this.activateUser(user.id);
async restore(user: UserType) {
this.actionPromise = this.restoreUser(user.id);
try {
await this.actionPromise;
this.platformUtilsService.showToast(
@ -381,18 +381,10 @@ export abstract class BasePeopleComponent<
return !searching && this.users && this.users.length > this.pageSize;
}
protected deleteWarningMessage(user: UserType): string {
return this.i18nService.t("removeUserConfirmation");
}
protected deactivateWarningMessage(): string {
protected revokeWarningMessage(): string {
return this.i18nService.t("revokeUserConfirmation");
}
protected activateWarningMessage(): string {
return this.i18nService.t("activateUserConfirmation");
}
protected getCheckedUsers() {
return this.users.filter((u) => (u as any).checked);
}

View File

@ -29,8 +29,8 @@ import { NavbarComponent } from "../layouts/navbar.component";
import { UserLayoutComponent } from "../layouts/user-layout.component";
import { OrganizationLayoutComponent } from "../organizations/layouts/organization-layout.component";
import { BulkConfirmComponent as OrgBulkConfirmComponent } from "../organizations/manage/bulk/bulk-confirm.component";
import { BulkDeactivateComponent as OrgBulkDeactivateomponent } from "../organizations/manage/bulk/bulk-deactivate.component";
import { BulkRemoveComponent as OrgBulkRemoveComponent } from "../organizations/manage/bulk/bulk-remove.component";
import { BulkRestoreRevokeComponent as OrgBulkRestoreRevokeComponent } from "../organizations/manage/bulk/bulk-restore-revoke.component";
import { BulkStatusComponent as OrgBulkStatusComponent } from "../organizations/manage/bulk/bulk-status.component";
import { CollectionAddEditComponent as OrgCollectionAddEditComponent } from "../organizations/manage/collection-add-edit.component";
import { CollectionsComponent as OrgManageCollectionsComponent } from "../organizations/manage/collections.component";
@ -237,7 +237,7 @@ import { OrganizationBadgeModule } from "./vault/modules/organization-badge/orga
OrganizationSubscriptionComponent,
OrgAttachmentsComponent,
OrgBulkConfirmComponent,
OrgBulkDeactivateomponent,
OrgBulkRestoreRevokeComponent,
OrgBulkRemoveComponent,
OrgBulkStatusComponent,
OrgCiphersComponent,
@ -390,7 +390,7 @@ import { OrganizationBadgeModule } from "./vault/modules/organization-badge/orga
OrganizationSubscriptionComponent,
OrgAttachmentsComponent,
OrgBulkConfirmComponent,
OrgBulkDeactivateomponent,
OrgBulkRestoreRevokeComponent,
OrgBulkRemoveComponent,
OrgBulkStatusComponent,
OrgCiphersComponent,

View File

@ -22,7 +22,7 @@
{{ error }}
</app-callout>
<ng-container *ngIf="!done">
<app-callout type="warning" *ngIf="users.length > 0 && !error && isDeactivating">
<app-callout type="warning" *ngIf="users.length > 0 && !error && isRevoking">
{{ "revokeUsersWarning" | i18n }}
</app-callout>
<table class="table table-hover table-list">

View File

@ -8,11 +8,11 @@ import { OrganizationUserBulkRequest } from "@bitwarden/common/models/request/or
import { BulkUserDetails } from "./bulk-status.component";
@Component({
selector: "app-bulk-deactivate",
templateUrl: "bulk-deactivate.component.html",
selector: "app-bulk-restore-revoke",
templateUrl: "bulk-restore-revoke.component.html",
})
export class BulkDeactivateComponent {
isDeactivating: boolean;
export class BulkRestoreRevokeComponent {
isRevoking: boolean;
organizationId: string;
users: BulkUserDetails[];
@ -27,13 +27,13 @@ export class BulkDeactivateComponent {
protected i18nService: I18nService,
config: ModalConfig
) {
this.isDeactivating = config.data.isDeactivating;
this.isRevoking = config.data.isRevoking;
this.organizationId = config.data.organizationId;
this.users = config.data.users;
}
get bulkTitle() {
const titleKey = this.isDeactivating ? "revokeUsers" : "restoreUsers";
const titleKey = this.isRevoking ? "revokeUsers" : "restoreUsers";
return this.i18nService.t(titleKey);
}
@ -42,7 +42,7 @@ export class BulkDeactivateComponent {
try {
const response = await this.performBulkUserAction();
const bulkMessage = this.isDeactivating ? "bulkRevokedMessage" : "bulkRestoredMessage";
const bulkMessage = this.isRevoking ? "bulkRevokedMessage" : "bulkRestoredMessage";
response.data.forEach((entry) => {
const error = entry.error !== "" ? entry.error : this.i18nService.t(bulkMessage);
this.statuses.set(entry.id, error);
@ -57,10 +57,10 @@ export class BulkDeactivateComponent {
protected async performBulkUserAction() {
const request = new OrganizationUserBulkRequest(this.users.map((user) => user.id));
if (this.isDeactivating) {
return await this.apiService.deactivateManyOrganizationUsers(this.organizationId, request);
if (this.isRevoking) {
return await this.apiService.revokeManyOrganizationUsers(this.organizationId, request);
} else {
return await this.apiService.activateManyOrganizationUsers(this.organizationId, request);
return await this.apiService.restoreManyOrganizationUsers(this.organizationId, request);
}
}
}

View File

@ -32,11 +32,11 @@
<button
type="button"
class="btn btn-outline-secondary"
[ngClass]="{ active: status == userStatusType.Deactivated }"
(click)="filter(userStatusType.Deactivated)"
[ngClass]="{ active: status == userStatusType.Revoked }"
(click)="filter(userStatusType.Revoked)"
>
{{ "revoked" | i18n }}
<span bitBadge badgeType="info" *ngIf="deactivatedCount">{{ deactivatedCount }}</span>
<span bitBadge badgeType="info" *ngIf="revokedCount">{{ revokedCount }}</span>
</button>
</div>
<div class="ml-3">
@ -75,11 +75,11 @@
<i class="bwi bwi-fw bwi-check" aria-hidden="true"></i>
{{ "confirmSelected" | i18n }}
</button>
<button class="dropdown-item" appStopClick (click)="bulkActivate()">
<button class="dropdown-item" appStopClick (click)="bulkRestore()">
<i class="bwi bwi-fw bwi-plus-circle" aria-hidden="true"></i>
{{ "restoreAccess" | i18n }}
</button>
<button class="dropdown-item" appStopClick (click)="bulkDeactivate()">
<button class="dropdown-item" appStopClick (click)="bulkRevoke()">
<i class="bwi bwi-fw bwi-minus-circle" aria-hidden="true"></i>
{{ "revokeAccess" | i18n }}
</button>
@ -158,7 +158,7 @@
<span bitBadge badgeType="warning" *ngIf="u.status === userStatusType.Accepted">{{
"accepted" | i18n
}}</span>
<span bitBadge badgeType="secondary" *ngIf="u.status === userStatusType.Deactivated">{{
<span bitBadge badgeType="secondary" *ngIf="u.status === userStatusType.Revoked">{{
"revoked" | i18n
}}</span>
<small class="text-muted d-block" *ngIf="u.name">{{ u.name }}</small>
@ -255,8 +255,8 @@
class="dropdown-item"
href="#"
appStopClick
(click)="activate(u)"
*ngIf="u.status === userStatusType.Deactivated"
(click)="restore(u)"
*ngIf="u.status === userStatusType.Revoked"
>
<i class="bwi bwi-fw bwi-plus-circle" aria-hidden="true"></i>
{{ "restoreAccess" | i18n }}
@ -265,8 +265,8 @@
class="dropdown-item"
href="#"
appStopClick
(click)="deactivate(u)"
*ngIf="u.status !== userStatusType.Deactivated"
(click)="revoke(u)"
*ngIf="u.status !== userStatusType.Revoked"
>
<i class="bwi bwi-fw bwi-minus-circle" aria-hidden="true"></i>
{{ "revokeAccess" | i18n }}

View File

@ -29,8 +29,8 @@ import { OrganizationUserUserDetailsResponse } from "@bitwarden/common/models/re
import { BasePeopleComponent } from "../../common/base.people.component";
import { BulkConfirmComponent } from "./bulk/bulk-confirm.component";
import { BulkDeactivateComponent } from "./bulk/bulk-deactivate.component";
import { BulkRemoveComponent } from "./bulk/bulk-remove.component";
import { BulkRestoreRevokeComponent } from "./bulk/bulk-restore-revoke.component";
import { BulkStatusComponent } from "./bulk/bulk-status.component";
import { EntityEventsComponent } from "./entity-events.component";
import { ResetPasswordComponent } from "./reset-password.component";
@ -167,12 +167,12 @@ export class PeopleComponent
return this.apiService.deleteOrganizationUser(this.organizationId, id);
}
deactivateUser(id: string): Promise<any> {
return this.apiService.deactivateOrganizationUser(this.organizationId, id);
revokeUser(id: string): Promise<any> {
return this.apiService.revokeOrganizationUser(this.organizationId, id);
}
activateUser(id: string): Promise<any> {
return this.apiService.activateOrganizationUser(this.organizationId, id);
restoreUser(id: string): Promise<any> {
return this.apiService.restoreOrganizationUser(this.organizationId, id);
}
reinviteUser(id: string): Promise<any> {
@ -245,11 +245,11 @@ export class PeopleComponent
modal.close();
this.removeUser(user);
});
comp.onDeactivatedUser.subscribe(() => {
comp.onRevokedUser.subscribe(() => {
modal.close();
this.load();
});
comp.onActivatedUser.subscribe(() => {
comp.onRestoredUser.subscribe(() => {
modal.close();
this.load();
});
@ -290,25 +290,25 @@ export class PeopleComponent
await this.load();
}
async bulkDeactivate() {
await this.bulkActivateOrDeactivate(true);
async bulkRevoke() {
await this.bulkRevokeOrRestore(true);
}
async bulkActivate() {
await this.bulkActivateOrDeactivate(false);
async bulkRestore() {
await this.bulkRevokeOrRestore(false);
}
async bulkActivateOrDeactivate(isDeactivating: boolean) {
async bulkRevokeOrRestore(isRevoking: boolean) {
if (this.actionPromise != null) {
return;
}
const ref = this.modalService.open(BulkDeactivateComponent, {
const ref = this.modalService.open(BulkRestoreRevokeComponent, {
allowMultipleModals: true,
data: {
organizationId: this.organizationId,
users: this.getCheckedUsers(),
isDeactivating: isDeactivating,
isRevoking: isRevoking,
},
});

View File

@ -11,7 +11,7 @@
<h2 class="modal-title" id="userAddEditTitle">
{{ title }}
<small class="text-muted" *ngIf="name">{{ name }}</small>
<span bitBadge badgeType="secondary" *ngIf="isDeactivated">{{ "revoked" | i18n }}</span>
<span bitBadge badgeType="secondary" *ngIf="isRevoked">{{ "revoked" | i18n }}</span>
</h2>
<button
type="button"
@ -381,9 +381,9 @@
<div class="ml-auto">
<button
type="button"
(click)="activate()"
(click)="restore()"
class="btn btn-outline-secondary"
*ngIf="editMode && isDeactivated"
*ngIf="editMode && isRevoked"
[disabled]="form.loading"
>
<i
@ -396,9 +396,9 @@
</button>
<button
type="button"
(click)="deactivate()"
(click)="revoke()"
class="btn btn-outline-secondary"
*ngIf="editMode && !isDeactivated"
*ngIf="editMode && !isRevoked"
[disabled]="form.loading"
>
<i

View File

@ -27,12 +27,12 @@ export class UserAddEditComponent implements OnInit {
@Input() usesKeyConnector = false;
@Output() onSavedUser = new EventEmitter();
@Output() onDeletedUser = new EventEmitter();
@Output() onDeactivatedUser = new EventEmitter();
@Output() onActivatedUser = new EventEmitter();
@Output() onRevokedUser = new EventEmitter();
@Output() onRestoredUser = new EventEmitter();
loading = true;
editMode = false;
isDeactivated = false;
isRevoked = false;
title: string;
emails: string;
type: OrganizationUserType = OrganizationUserType.User;
@ -101,7 +101,7 @@ export class UserAddEditComponent implements OnInit {
);
this.access = user.accessAll ? "all" : "selected";
this.type = user.type;
this.isDeactivated = user.status === OrganizationUserStatusType.Deactivated;
this.isRevoked = user.status === OrganizationUserStatusType.Revoked;
if (user.type === OrganizationUserType.Custom) {
this.permissions = user.permissions;
}
@ -245,7 +245,7 @@ export class UserAddEditComponent implements OnInit {
}
}
async deactivate() {
async revoke() {
if (!this.editMode) {
return;
}
@ -262,7 +262,7 @@ export class UserAddEditComponent implements OnInit {
}
try {
this.formPromise = this.apiService.deactivateOrganizationUser(
this.formPromise = this.apiService.revokeOrganizationUser(
this.organizationId,
this.organizationUserId
);
@ -272,20 +272,20 @@ export class UserAddEditComponent implements OnInit {
null,
this.i18nService.t("revokedUserId", this.name)
);
this.isDeactivated = true;
this.onDeactivatedUser.emit();
this.isRevoked = true;
this.onRevokedUser.emit();
} catch (e) {
this.logService.error(e);
}
}
async activate() {
async restore() {
if (!this.editMode) {
return;
}
try {
this.formPromise = this.apiService.activateOrganizationUser(
this.formPromise = this.apiService.restoreOrganizationUser(
this.organizationId,
this.organizationUserId
);
@ -295,8 +295,8 @@ export class UserAddEditComponent implements OnInit {
null,
this.i18nService.t("restoredUserId", this.name)
);
this.isDeactivated = false;
this.onActivatedUser.emit();
this.isRevoked = false;
this.onRestoredUser.emit();
} catch (e) {
this.logService.error(e);
}

View File

@ -280,14 +280,14 @@ export class EventService {
this.getShortId(ev.organizationUserId)
);
break;
case EventType.OrganizationUser_Deactivated:
case EventType.OrganizationUser_Revoked:
msg = this.i18nService.t("revokedUserId", this.formatOrgUserId(ev));
humanReadableMsg = this.i18nService.t(
"revokedUserId",
this.getShortId(ev.organizationUserId)
);
break;
case EventType.OrganizationUser_Activated:
case EventType.OrganizationUser_Restored:
msg = this.i18nService.t("restoredUserId", this.formatOrgUserId(ev));
humanReadableMsg = this.i18nService.t(
"restoredUserId",

View File

@ -120,12 +120,12 @@ export class PeopleComponent
return this.apiService.deleteProviderUser(this.providerId, id);
}
deactivateUser(id: string): Promise<any> {
revokeUser(id: string): Promise<any> {
// Not implemented.
return null;
}
activateUser(id: string): Promise<any> {
restoreUser(id: string): Promise<any> {
// Not implemented.
return null;
}

View File

@ -449,13 +449,13 @@ export abstract class ApiService {
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
deactivateOrganizationUser: (organizationId: string, id: string) => Promise<any>;
deactivateManyOrganizationUsers: (
revokeOrganizationUser: (organizationId: string, id: string) => Promise<any>;
revokeManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
activateOrganizationUser: (organizationId: string, id: string) => Promise<any>;
activateManyOrganizationUsers: (
restoreOrganizationUser: (organizationId: string, id: string) => Promise<any>;
restoreManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;

View File

@ -48,8 +48,8 @@ export enum EventType {
OrganizationUser_AdminResetPassword = 1508,
OrganizationUser_ResetSsoLink = 1509,
OrganizationUser_FirstSsoLogin = 1510,
OrganizationUser_Deactivated = 1511,
OrganizationUser_Activated = 1512,
OrganizationUser_Revoked = 1511,
OrganizationUser_Restored = 1512,
Organization_Updated = 1600,
Organization_PurgedVault = 1601,

View File

@ -2,5 +2,5 @@ export enum OrganizationUserStatusType {
Invited = 0,
Accepted = 1,
Confirmed = 2,
Deactivated = -1,
Revoked = -1,
}

View File

@ -2,5 +2,5 @@ export enum ProviderUserStatusType {
Invited = 0,
Accepted = 1,
Confirmed = 2,
Deactivated = -1, // Not used, compile-time support only
Revoked = -1, // Not used, compile-time support only
}

View File

@ -1344,23 +1344,23 @@ export class ApiService implements ApiServiceAbstraction {
return new ListResponse(r, OrganizationUserBulkResponse);
}
deactivateOrganizationUser(organizationId: string, id: string): Promise<any> {
revokeOrganizationUser(organizationId: string, id: string): Promise<any> {
return this.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id + "/deactivate",
"/organizations/" + organizationId + "/users/" + id + "/revoke",
null,
true,
false
);
}
async deactivateManyOrganizationUsers(
async revokeManyOrganizationUsers(
organizationId: string,
request: OrganizationUserBulkRequest
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.send(
"PUT",
"/organizations/" + organizationId + "/users/deactivate",
"/organizations/" + organizationId + "/users/revoke",
request,
true,
true
@ -1368,23 +1368,23 @@ export class ApiService implements ApiServiceAbstraction {
return new ListResponse(r, OrganizationUserBulkResponse);
}
activateOrganizationUser(organizationId: string, id: string): Promise<any> {
restoreOrganizationUser(organizationId: string, id: string): Promise<any> {
return this.send(
"PUT",
"/organizations/" + organizationId + "/users/" + id + "/activate",
"/organizations/" + organizationId + "/users/" + id + "/restore",
null,
true,
false
);
}
async activateManyOrganizationUsers(
async restoreManyOrganizationUsers(
organizationId: string,
request: OrganizationUserBulkRequest
): Promise<ListResponse<OrganizationUserBulkResponse>> {
const r = await this.send(
"PUT",
"/organizations/" + organizationId + "/users/activate",
"/organizations/" + organizationId + "/users/restore",
request,
true,
true