Skip to content

Commit

Permalink
Merge pull request sap-labs-france#555 from sap-labs-france/authoriza…
Browse files Browse the repository at this point in the history
…tion

Updated SercurityProvider canAccess
  • Loading branch information
LucasBrazi06 authored Nov 16, 2021
2 parents e3bee20 + 1862d08 commit b902970
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/provider/SecurityProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,21 @@ export default class SecurityProvider {
}

public canAccess(resource: string, action: string): boolean {
return this.loggedUser && this.loggedUser.scopes && this.loggedUser.scopes.includes(`${resource}:${action}`);
return this.loggedUser && this.loggedUser.scopes && (this.loggedUser.scopes.includes(`${resource}:${action}`)
//TODO remove the plural (s) when backend new authorization deployed
|| this.loggedUser.scopes.includes(`${resource}s:${action}`));
}

public canListUsers(): boolean {
return this.canAccess(Entity.USER, Action.LIST);
}

public canListTags(): boolean {
return this.canAccess(Entity.TAGS, Action.LIST);
return this.canAccess(Entity.TAG, Action.LIST);
}

public canListCars(): boolean {
return this.canAccess(Entity.CARS, Action.LIST);
return this.canAccess(Entity.CAR, Action.LIST);
}

public canListInvoices(): boolean {
Expand Down

0 comments on commit b902970

Please sign in to comment.