Skip to content

Commit

Permalink
Only show voting button when user has voting rights
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Oct 6, 2023
1 parent fc7ccd7 commit f74d9cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Latest changes in each category go to the top
## [Unreleased]

### Added
- dev_login can change userId when clicking on the user in the upper right
- admin can now add users as voters
- New debugging variables in [local_vars.sh](./scripts/local_vars.sh)
- Changelog - please use it

Expand Down
6 changes: 1 addition & 5 deletions web/backend/src/authManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ export function isAuthorized(sciper: number | undefined, subject: string, action
}

export async function getUserPermissions(userID: number) {
let permissions: string[][] = [];
await authEnforcer.getFilteredPolicy(0, String(userID)).then((authRights) => {
permissions = authRights;
});
return permissions;
return authEnforcer.getFilteredPolicy(0, String(userID));
}

export function addPolicy(userID: string, subject: string, permission: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { ROUTE_BALLOT_SHOW } from 'Routes';
import { Status } from 'types/form';

const VoteButton = ({ status, formID }) => {
const authCtx = useContext(AuthContext);
const { isLogged } = useContext(AuthContext);
const { t } = useTranslation();

return (
authCtx.isAllowed(formID, 'vote') &&
status === Status.Open &&
isLogged && (
<Link to={ROUTE_BALLOT_SHOW + '/' + formID}>
Expand Down

0 comments on commit f74d9cd

Please sign in to comment.