Skip to content

bug(auth): non admin users can access protected admin pages #246

@SagitQuark

Description

@SagitQuark

Description

While testing admin workflows, I noticed that a user authenticated with a regular customer account is still able to access and navigate through admin routes.

Although backend authorization correctly prevents restricted operations, the admin interface itself is rendered and remains accessible until an admin-only action triggers a protected API request.

Current Behavior

A customer account can access pages intended for administrative users, including areas such as:

  • Dashboard
  • Orders
  • Menu Management
  • Store Management

The admin UI loads successfully and can be navigated normally.

However, when the user attempts an admin only action (for example creating menus, branches, or other management operations), the backend responds with a 403 Forbidden error and the user is eventually redirected to the login page.

Observed Impact

This creates an inconsistent authorization experience where:

  1. Non-admin users can view and interact with administrative interfaces.
  2. Access is only denied after an API request is made.
  3. The user is redirected only after backend authorization fails.

As a result, users are able to reach protected admin pages even though they do not have the required permissions to perform administrative operations.

Steps to Reproduce

  1. Sign in using a customer account.
  2. Navigate to an admin route (e.g. Dashboard, Orders, Menus, Store Management).
  3. Observe that the admin interface loads successfully.
  4. Attempt an admin only action.
  5. Observe that the backend returns a 403 Forbidden response and the user is redirected.

Expected Behavior

Users without the required administrative role should not be able to access protected admin routes.

Attempting to access /admin/* routes with a non admin account should immediately:

  • Redirect the user to an appropriate page, or
  • Display an unauthorized access view,

without rendering the admin interface.

Additional Context

While investigating this behavior, I observed that backend authorization is functioning correctly and returns 403 Forbidden responses for restricted operations.

The issue appears to be that route level protection allows authenticated users to access admin pages before role based authorization is enforced.

Screenshot attached showing a customer account successfully accessing the admin dashboard.

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions