1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

restrict access based on org permissions

This commit is contained in:
Kyle Spearrin 2018-07-10 09:19:29 -04:00
parent ddd832d016
commit febc3093a9
5 changed files with 45 additions and 9 deletions

2
jslib

@ -1 +1 @@
Subproject commit 049e129f3647ee807bdc68a3d0a38854b4ba0256 Subproject commit 36ab2ec78b0b235008312ab70c16882d28fd76b7

View File

@ -2,12 +2,13 @@ import {
Component, Component,
OnInit, OnInit,
} from '@angular/core'; } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { UserService } from 'jslib/abstractions/user.service';
import { EventService } from '../../services/event.service'; import { EventService } from '../../services/event.service';
@ -34,11 +35,17 @@ export class EventsComponent implements OnInit {
constructor(private apiService: ApiService, private route: ActivatedRoute, constructor(private apiService: ApiService, private route: ActivatedRoute,
private eventService: EventService, private i18nService: I18nService, private eventService: EventService, private i18nService: I18nService,
private toasterService: ToasterService) { } private toasterService: ToasterService, private userService: UserService,
private router: Router) { }
async ngOnInit() { async ngOnInit() {
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId; this.organizationId = params.organizationId;
const organization = await this.userService.getOrganization(this.organizationId);
if (organization == null || !organization.useEvents) {
this.router.navigate(['/organizations', this.organizationId]);
return;
}
const defaultDates = this.eventService.getDefaultDateFilters(); const defaultDates = this.eventService.getDefaultDateFilters();
this.start = defaultDates[0]; this.start = defaultDates[0];
this.end = defaultDates[1]; this.end = defaultDates[1];

View File

@ -5,7 +5,10 @@ import {
ViewChild, ViewChild,
ViewContainerRef, ViewContainerRef,
} from '@angular/core'; } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import {
ActivatedRoute,
Router,
} from '@angular/router';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2'; import { Angulartics2 } from 'angulartics2';
@ -13,6 +16,7 @@ import { Angulartics2 } from 'angulartics2';
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.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 { GroupResponse } from 'jslib/models/response/groupResponse'; import { GroupResponse } from 'jslib/models/response/groupResponse';
@ -40,11 +44,17 @@ export class GroupsComponent implements OnInit {
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 analytics: Angulartics2, private toasterService: ToasterService, private analytics: Angulartics2, private toasterService: ToasterService,
private platformUtilsService: PlatformUtilsService) { } private platformUtilsService: PlatformUtilsService, private userService: UserService,
private router: Router) { }
async ngOnInit() { async ngOnInit() {
this.route.parent.parent.params.subscribe(async (params) => { this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId; this.organizationId = params.organizationId;
const organization = await this.userService.getOrganization(this.organizationId);
if (organization == null || !organization.useGroups) {
this.router.navigate(['/organizations', this.organizationId]);
return;
}
await this.load(); await this.load();
}); });
} }

View File

@ -10,10 +10,10 @@
<a routerLink="collections" class="list-group-item" routerLinkActive="active"> <a routerLink="collections" class="list-group-item" routerLinkActive="active">
{{'collections' | i18n}} {{'collections' | i18n}}
</a> </a>
<a routerLink="groups" class="list-group-item" routerLinkActive="active"> <a routerLink="groups" class="list-group-item" routerLinkActive="active" *ngIf="accessGroups">
{{'groups' | i18n}} {{'groups' | i18n}}
</a> </a>
<a routerLink="events" class="list-group-item" routerLinkActive="active"> <a routerLink="events" class="list-group-item" routerLinkActive="active" *ngIf="accessEvents">
{{'eventLogs' | i18n}} {{'eventLogs' | i18n}}
</a> </a>
</div> </div>

View File

@ -1,7 +1,26 @@
import { Component } from '@angular/core'; import {
Component,
OnInit,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UserService } from 'jslib/abstractions/user.service';
@Component({ @Component({
selector: 'app-org-manage', selector: 'app-org-manage',
templateUrl: 'manage.component.html', templateUrl: 'manage.component.html',
}) })
export class ManageComponent { } export class ManageComponent implements OnInit {
accessGroups = false;
accessEvents = false;
constructor(private route: ActivatedRoute, private userService: UserService) { }
ngOnInit() {
this.route.parent.params.subscribe(async (params) => {
const organization = await this.userService.getOrganization(params.organizationId);
this.accessEvents = organization.useEvents;
this.accessGroups = organization.useGroups;
});
}
}