Skip to content

Commit

Permalink
Allow all program managers to change status from planning to started
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksTeresh committed Dec 12, 2024
1 parent 64cc882 commit 8052c0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/client/components/ThesisPage/ThesisEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ const ThesisEditForm: FC<{
disabled={
initialThesis.status === 'PLANNING' &&
!user.isAdmin &&
!user.approvableProgramIds?.includes(editedThesis.programId)
!user.managedProgramIds?.includes(editedThesis.programId)
}
value={editedThesis.status}
label={t('statusHeader')}
Expand Down
12 changes: 6 additions & 6 deletions src/server/middleware/authorizeStatusChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ export const authorizeStatusChange = async (
// and the user is trying to update it
// to something else than PLANNING,
// then we need to check permissions i.e.
// only allow it if the user is an approver-program-manager
const programsWhereUserIsApprover = await ProgramManagement.findAll({
// only allow it if the user is a-program-manager
const programsWhereUserIsManager = await ProgramManagement.findAll({
attributes: ['programId'],
where: { userId: actionUser.id, isThesisApprover: true },
where: { userId: actionUser.id },
})
const programIdsWhereUserIsApprover = programsWhereUserIsApprover.map(
const programIdsWhereUserIsManager = programsWhereUserIsManager.map(
(program) => program.programId
)

if (!programIdsWhereUserIsApprover.includes(req.body.programId)) {
// if the user is not an approver-program-manager and the status
if (!programIdsWhereUserIsManager.includes(req.body.programId)) {
// if the user is not a program-manager and the status
// is changed or the thesis a new one throw an Authorization error
if (!thesis || thesis.status !== req.body.status) {
throw new CustomAuthorizationError(
Expand Down

0 comments on commit 8052c0c

Please sign in to comment.