mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
check group access on collection edit page
This commit is contained in:
parent
9aa8699617
commit
a25f6dee73
@ -15,6 +15,7 @@
|
|||||||
<label for="name">{{'name' | i18n}}</label>
|
<label for="name">{{'name' | i18n}}</label>
|
||||||
<input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name" required>
|
<input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name" required>
|
||||||
</div>
|
</div>
|
||||||
|
<ng-container *ngIf="accessGroups">
|
||||||
<h3 class="mt-4 d-flex mb-0">
|
<h3 class="mt-4 d-flex mb-0">
|
||||||
{{'groupAccess' | i18n}}
|
{{'groupAccess' | i18n}}
|
||||||
<div class="ml-auto" *ngIf="groups && groups.length">
|
<div class="ml-auto" *ngIf="groups && groups.length">
|
||||||
@ -54,6 +55,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
||||||
|
@ -13,6 +13,7 @@ import { ApiService } from 'jslib/abstractions/api.service';
|
|||||||
import { CryptoService } from 'jslib/abstractions/crypto.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 { UserService } from 'jslib/abstractions/user.service';
|
||||||
|
|
||||||
import { CipherString } from 'jslib/models/domain/cipherString';
|
import { CipherString } from 'jslib/models/domain/cipherString';
|
||||||
import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey';
|
import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey';
|
||||||
@ -34,6 +35,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
editMode: boolean = false;
|
editMode: boolean = false;
|
||||||
|
accessGroups: boolean = false;
|
||||||
title: string;
|
title: string;
|
||||||
name: string;
|
name: string;
|
||||||
groups: GroupResponse[] = [];
|
groups: GroupResponse[] = [];
|
||||||
@ -44,12 +46,17 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||||
private analytics: Angulartics2, private toasterService: ToasterService,
|
private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService) { }
|
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
|
||||||
|
private userService: UserService) { }
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
const organization = await this.userService.getOrganization(this.organizationId);
|
||||||
|
this.accessGroups = organization.useGroups;
|
||||||
this.editMode = this.loading = this.collectionId != null;
|
this.editMode = this.loading = this.collectionId != null;
|
||||||
|
if (this.accessGroups) {
|
||||||
const groupsResponse = await this.apiService.getGroups(this.organizationId);
|
const groupsResponse = await this.apiService.getGroups(this.organizationId);
|
||||||
this.groups = groupsResponse.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, 'name'));
|
this.groups = groupsResponse.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, 'name'));
|
||||||
|
}
|
||||||
this.orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
this.orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||||
|
|
||||||
if (this.editMode) {
|
if (this.editMode) {
|
||||||
@ -58,7 +65,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const collection = await this.apiService.getCollectionDetails(this.organizationId, this.collectionId);
|
const collection = await this.apiService.getCollectionDetails(this.organizationId, this.collectionId);
|
||||||
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
|
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
|
||||||
if (collection.groups != null && this.groups != null) {
|
if (collection.groups != null && this.groups.length > 0) {
|
||||||
collection.groups.forEach((s) => {
|
collection.groups.forEach((s) => {
|
||||||
const group = this.groups.filter((g) => !g.accessAll && g.id === s.id);
|
const group = this.groups.filter((g) => !g.accessAll && g.id === s.id);
|
||||||
if (group != null && group.length > 0) {
|
if (group != null && group.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user