refactor: enum voor account types
This commit is contained in:
		
							parent
							
								
									f9fc19d8a6
								
							
						
					
					
						commit
						fc0d3b5c84
					
				
					 20 changed files with 77 additions and 5870 deletions
				
			
		|  | @ -2,6 +2,7 @@ import { authorize } from './auth-checks.js'; | |||
| import { fetchClass } from '../../../services/classes.js'; | ||||
| import { fetchGroup } from '../../../services/groups.js'; | ||||
| import { mapToUsername } from '../../../interfaces/user.js'; | ||||
| import {AccountType} from "@dwengo-1/common/util/account-types"; | ||||
| 
 | ||||
| /** | ||||
|  * Expects the path to contain the path parameters 'classid', 'assignmentid' and 'groupid'. | ||||
|  | @ -16,7 +17,7 @@ export const onlyAllowIfHasAccessToGroup = authorize(async (auth, req) => { | |||
|         groupid: groupId, | ||||
|     } = req.params as { classid: string; assignmentid: number; groupid: number }; | ||||
| 
 | ||||
|     if (auth.accountType === 'teacher') { | ||||
|     if (auth.accountType === AccountType.Teacher) { | ||||
|         const clazz = await fetchClass(classId); | ||||
|         return clazz.teachers.map(mapToUsername).includes(auth.username); | ||||
|     } // User is student
 | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl