You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#3881 - Validate user account for all routes (#3985)
# Validate user account for all routes
## New global guard and decorator
- [x] New guard `RequiresUserAccountGuard` has been introduced globally
to ensure that routes are authorized with the user token which belongs
to valid SIMS user. There are exceptional routes like public routes and
routes used that setup the user itself are skipped from this validation.
- [x] New decorator `@RequiresUserAccount()` is introduced to get the
metadata context for the guard.
## Student page container
- [x] Student page container updated to NOT render restriction and SIN
banners for pages which does not require a valid student account.
## E2E Tests
- [x] The existing method to mock the student info from token
`mockUserLoginInfo()` does not have a way to restore the mock, if the
mock needs to be restored for other tests in same suite.
Hence refactored the code to use `jest.spyOn()` to mock the userService
method implementation and also created a reset mock method to reset the
mock as required in the test suite.
Here is an example.
**Mock applied**

**Mock Reset**

- [x] Created new Auth E2E tests

## Volar extension
- [x] Updated the workspace file with deprecated vue extension by
replacing with recommended extension.

Copy file name to clipboardExpand all lines: sources/packages/backend/apps/api/src/route-controllers/assessment/_tests_/e2e/assessment.students.controller.getAssessmentAwardDetails.e2e-spec.ts
Copy file name to clipboardExpand all lines: sources/packages/backend/apps/api/src/route-controllers/institution-user/institution-user.institutions.controller.ts
Copy file name to clipboardExpand all lines: sources/packages/backend/apps/api/src/route-controllers/institution/institution.institutions.controller.ts
+3
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ import { AuthorizedParties } from "../../auth/authorized-parties.enum";
Copy file name to clipboardExpand all lines: sources/packages/backend/apps/api/src/route-controllers/student-account-applications/student-account-application.students.controller.ts
+3
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ import { AuthorizedParties } from "../../auth/authorized-parties.enum";
17
17
import{
18
18
AllowAuthorizedParty,
19
19
RequiresStudentAccount,
20
+
RequiresUserAccount,
20
21
UserToken,
21
22
}from"../../auth/decorators";
22
23
importBaseControllerfrom"../BaseController";
@@ -66,6 +67,7 @@ export class StudentAccountApplicationStudentsController extends BaseController
66
67
"There is already a student account application in progress or the user is already present.",
67
68
})
68
69
@Post()
70
+
@RequiresUserAccount(false)
69
71
@RequiresStudentAccount(false)
70
72
asynccreate(
71
73
@UserToken()userToken: IUserToken,
@@ -110,6 +112,7 @@ export class StudentAccountApplicationStudentsController extends BaseController
110
112
* @returns true if there is a pending student account application
111
113
* to be assessed by the Ministry, otherwise, false.
Copy file name to clipboardExpand all lines: sources/packages/backend/apps/api/src/route-controllers/supporting-user/supporting-user.supporting-users.controller.ts
0 commit comments