Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Ministry User #3881

Closed
7 tasks done
ninosamson opened this issue Nov 1, 2024 · 0 comments
Closed
7 tasks done

Validate Ministry User #3881

ninosamson opened this issue Nov 1, 2024 · 0 comments
Assignees
Labels
Ministry Ministry Features

Comments

@ninosamson
Copy link
Collaborator

ninosamson commented Nov 1, 2024

User Story:
As SIMS, we need to validate that all ministry users have user profiles, otherwise they should not be able to function in the app.

Acceptance Criteria:

  • Add validation for ministry account users to require a user profile (users table).
  • If a user logs in and has no user profile or does not have enough information to create a user profile (example: missing email) they should be redirected to the login page and receive the same message as an unauthorized user with no user profile.

Context:

  • During onboarding of contracted users, we noticed that some navigation in the system was possible even though the mandatory email in their profile was not present. Emails will continue to be mandatory, so if users does not have a user profile, they should not be able to navigate the system.

Technical

  • Create a guard to validate if the user exists.
  • Crate a decorator to allow the user to not exist for some endpoints, for instance, the ones that need to create the user.
  • Please use the RequiresStudentAccountGuard as a reference and the RequiresStudentAccount as a decorator reference to allow certain endpoints to be reach even without a user created, for instance, for the endpoints actually creating the user.
  • Apply this guard globally.
  • Create a test into the existing auth.e2e-spec.ts.
@ninosamson ninosamson added the Business Items under Business Consideration label Nov 1, 2024
@CarlyCotton CarlyCotton self-assigned this Nov 4, 2024
@CarlyCotton CarlyCotton added the Ministry Ministry Features label Nov 4, 2024
@Joshua-Lakusta Joshua-Lakusta added Dev & Architecture Development and Architecture and removed Business Items under Business Consideration labels Nov 5, 2024
@andrewsignori-aot andrewsignori-aot removed the Dev & Architecture Development and Architecture label Nov 5, 2024
@dheepak-aot dheepak-aot self-assigned this Nov 15, 2024
github-merge-queue bot pushed a commit that referenced this issue Nov 25, 2024
# 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**


![image](https://github.com/user-attachments/assets/9f0277d8-27c9-4c1a-98d0-8fd5fc5583a8)

**Mock Reset**

![image](https://github.com/user-attachments/assets/0e9115b3-d456-43eb-aace-d282d68d5297)

- [x] Created new Auth E2E tests


![image](https://github.com/user-attachments/assets/b3e48542-c314-4ee7-81e3-6807a6ea32f6)


## Volar extension

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

![image](https://github.com/user-attachments/assets/1ee3de6f-b315-4d87-acd2-32f58dce0891)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ministry Ministry Features
Projects
None yet
Development

No branches or pull requests

5 participants