Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file added src/assets/screenshots/ports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/screenshots/repos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/screenshots/unauthorised-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/screenshots/unauthorised.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions src/pages/admin-access-control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Admin Access Control
layout: ../layouts/BaseLayout.astro
---

# Admin Access Control Implementation

## Overview
This documentation explains the implementation of admin access restrictions in the frontend of the OnTrack system under the Capstone project with Thoth Tech.

## Technologies Used
- Angular (routing and guards)
- Visual Studio Code
- Git (feature/admin-access-control branch)
- Astro Framework (for documentation)
- Node.js + Dev Containers

## Key Actions
- Set up dev environment and confirmed running ports (4200 for frontend).
- Implemented route guards to restrict `/admin/units` from student access.
- Redirected unauthorized users to a dashboard or error page.
- Used a dedicated Git branch to manage changes safely.
---

## Testing Methodology

### Manual Testing Approach

The admin access control functionality was manually tested in a local development container using the Angular app served at `localhost:4200`.

- **Step 1:** Log in with a **student/non-admin account**.
- **Step 2:** Attempt to visit the admin route: `/#/admin/units`.
- **Expected Result:** The student should be redirected to a non-admin page (dashboard or error).
- **Actual Result:** The user was redirected and shown a page with the message:
> “You are not enrolled in any OnTrack units.”

✅ This confirms that unauthorized users are blocked from admin content.

### Screenshot (Test Output)

![Unauthorized Output](../assets/screenshots/unauthorised-result.png)

---

## Conclusion

This test confirms that the admin route protection is working as intended. Future improvements may include automated testing using Angular's testing tools or Cypress.

## Screenshots
- Unauthorized access test:
![Unauthorized Access](../assets/screenshots/unauthorised.png)

- Repo forked view:
![Repositories](../assets/screenshots/repos.png)

- Ports in dev container:
![Ports](../assets/screenshots/ports.png)

## Notes
This restriction improves user experience and protects sensitive admin features from misuse.