mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
reinvite and confirm users
This commit is contained in:
2
jslib
2
jslib
Submodule jslib updated: e9518e104e...d7f3f9425e
@@ -50,6 +50,14 @@
|
|||||||
<i class="fa fa-cog fa-lg"></i>
|
<i class="fa fa-cog fa-lg"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
|
<a class="dropdown-item" href="#" appStopClick (click)="reinvite(u)" *ngIf="u.status === organizationUserStatusType.Invited">
|
||||||
|
<i class="fa fa-fw fa-envelope-o"></i>
|
||||||
|
{{'resendInvitation' | i18n}}
|
||||||
|
</a>
|
||||||
|
<a class="dropdown-item text-success" href="#" appStopClick (click)="confirm(u)" *ngIf="u.status === organizationUserStatusType.Accepted">
|
||||||
|
<i class="fa fa-fw fa-check"></i>
|
||||||
|
{{'confirm' | i18n}}
|
||||||
|
</a>
|
||||||
<a class="dropdown-item" href="#" appStopClick (click)="groups(u)">
|
<a class="dropdown-item" href="#" appStopClick (click)="groups(u)">
|
||||||
<i class="fa fa-fw fa-sitemap"></i>
|
<i class="fa fa-fw fa-sitemap"></i>
|
||||||
{{'groups' | i18n}}
|
{{'groups' | i18n}}
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ import { ToasterService } from 'angular2-toaster';
|
|||||||
import { Angulartics2 } from 'angulartics2';
|
import { Angulartics2 } from 'angulartics2';
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
|
||||||
|
import { OrganizationUserConfirmRequest } from 'jslib/models/request/organizationUserConfirmRequest';
|
||||||
|
|
||||||
import { OrganizationUserUserDetailsResponse } from 'jslib/models/response/organizationUserResponse';
|
import { OrganizationUserUserDetailsResponse } from 'jslib/models/response/organizationUserResponse';
|
||||||
|
|
||||||
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
|
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
|
||||||
@@ -39,13 +42,14 @@ export class PeopleComponent implements OnInit {
|
|||||||
searchText: string;
|
searchText: string;
|
||||||
organizationUserType = OrganizationUserType;
|
organizationUserType = OrganizationUserType;
|
||||||
organizationUserStatusType = OrganizationUserStatusType;
|
organizationUserStatusType = OrganizationUserStatusType;
|
||||||
|
actionPromise: Promise<any>;
|
||||||
|
|
||||||
private modal: ModalComponent = null;
|
private modal: ModalComponent = null;
|
||||||
|
|
||||||
constructor(private apiService: ApiService, private route: ActivatedRoute,
|
constructor(private apiService: ApiService, private route: ActivatedRoute,
|
||||||
private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver,
|
private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver,
|
||||||
private platformUtilsService: PlatformUtilsService, private analytics: Angulartics2,
|
private platformUtilsService: PlatformUtilsService, private analytics: Angulartics2,
|
||||||
private toasterService: ToasterService) { }
|
private toasterService: ToasterService, private cryptoService: CryptoService) { }
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.route.parent.parent.params.subscribe(async (params) => {
|
this.route.parent.parent.params.subscribe(async (params) => {
|
||||||
@@ -131,6 +135,43 @@ export class PeopleComponent implements OnInit {
|
|||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reinvite(user: OrganizationUserUserDetailsResponse) {
|
||||||
|
if (this.actionPromise != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.actionPromise = this.apiService.postOrganizationUserReinvite(this.organizationId, user.id);
|
||||||
|
await this.actionPromise;
|
||||||
|
this.analytics.eventTrack.next({ action: 'Reinvited User' });
|
||||||
|
this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenReinvited', user.name || user.email));
|
||||||
|
this.actionPromise = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async confirm(user: OrganizationUserUserDetailsResponse) {
|
||||||
|
if (this.actionPromise != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.actionPromise = this.doConfirmation(user);
|
||||||
|
await this.actionPromise;
|
||||||
|
user.status = OrganizationUserStatusType.Confirmed;
|
||||||
|
this.analytics.eventTrack.next({ action: 'Confirmed User' });
|
||||||
|
this.toasterService.popAsync('success', null, this.i18nService.t('hasBeenConfirmed', user.name || user.email));
|
||||||
|
this.actionPromise = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async events(user: OrganizationUserUserDetailsResponse) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async doConfirmation(user: OrganizationUserUserDetailsResponse) {
|
||||||
|
const orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||||
|
const publicKeyResponse = await this.apiService.getUserPublicKey(user.userId);
|
||||||
|
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
|
||||||
|
const key = await this.cryptoService.rsaEncrypt(orgKey.key, publicKey.buffer);
|
||||||
|
const request = new OrganizationUserConfirmRequest();
|
||||||
|
request.key = key.encryptedString;
|
||||||
|
await this.apiService.postOrganizationUserConfirm(this.organizationId, user.id, request);
|
||||||
|
}
|
||||||
|
|
||||||
private removeUser(user: OrganizationUserUserDetailsResponse) {
|
private removeUser(user: OrganizationUserUserDetailsResponse) {
|
||||||
const index = this.users.indexOf(user);
|
const index = this.users.indexOf(user);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
|
|||||||
@@ -2053,5 +2053,29 @@
|
|||||||
},
|
},
|
||||||
"invitedUsers": {
|
"invitedUsers": {
|
||||||
"message": "Invited user(s)."
|
"message": "Invited user(s)."
|
||||||
|
},
|
||||||
|
"resendInvitation": {
|
||||||
|
"message": "Resend Invitation"
|
||||||
|
},
|
||||||
|
"hasBeenReinvited": {
|
||||||
|
"message": "$USER$ has been reinvited.",
|
||||||
|
"placeholders": {
|
||||||
|
"user": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "John Smith"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"confirm": {
|
||||||
|
"message": "Confirm"
|
||||||
|
},
|
||||||
|
"hasBeenConfirmed": {
|
||||||
|
"message": "$USER$ has been confirmed.",
|
||||||
|
"placeholders": {
|
||||||
|
"user": {
|
||||||
|
"content": "$1",
|
||||||
|
"example": "John Smith"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user