reinvite and confirm users
This commit is contained in:
parent
455df290bf
commit
1f7ca7386a
2
jslib
2
jslib
|
@ -1 +1 @@
|
|||
Subproject commit e9518e104e4d1bdfb24ea82071d28ef0b28061a7
|
||||
Subproject commit d7f3f9425ececd041bc1a3e0be3f9da157ac55c3
|
|
@ -50,6 +50,14 @@
|
|||
<i class="fa fa-cog fa-lg"></i>
|
||||
</button>
|
||||
<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)">
|
||||
<i class="fa fa-fw fa-sitemap"></i>
|
||||
{{'groups' | i18n}}
|
||||
|
|
|
@ -11,9 +11,12 @@ 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 { OrganizationUserConfirmRequest } from 'jslib/models/request/organizationUserConfirmRequest';
|
||||
|
||||
import { OrganizationUserUserDetailsResponse } from 'jslib/models/response/organizationUserResponse';
|
||||
|
||||
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
|
||||
|
@ -39,13 +42,14 @@ export class PeopleComponent implements OnInit {
|
|||
searchText: string;
|
||||
organizationUserType = OrganizationUserType;
|
||||
organizationUserStatusType = OrganizationUserStatusType;
|
||||
actionPromise: Promise<any>;
|
||||
|
||||
private modal: ModalComponent = null;
|
||||
|
||||
constructor(private apiService: ApiService, private route: ActivatedRoute,
|
||||
private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver,
|
||||
private platformUtilsService: PlatformUtilsService, private analytics: Angulartics2,
|
||||
private toasterService: ToasterService) { }
|
||||
private toasterService: ToasterService, private cryptoService: CryptoService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.route.parent.parent.params.subscribe(async (params) => {
|
||||
|
@ -131,6 +135,43 @@ export class PeopleComponent implements OnInit {
|
|||
} 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) {
|
||||
const index = this.users.indexOf(user);
|
||||
if (index > -1) {
|
||||
|
|
|
@ -2053,5 +2053,29 @@
|
|||
},
|
||||
"invitedUsers": {
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue