Skip to content

Integrate Auth to front end & move api documentation to our /docs page and remove scaler#7

Open
LEEDASILVA wants to merge 11 commits into
mainfrom
integrate-auth-api-to-client
Open

Integrate Auth to front end & move api documentation to our /docs page and remove scaler#7
LEEDASILVA wants to merge 11 commits into
mainfrom
integrate-auth-api-to-client

Conversation

@LEEDASILVA
Copy link
Copy Markdown
Collaborator

@LEEDASILVA LEEDASILVA commented Apr 19, 2026

Docs API

image

Auth

image

logout
image

@LEEDASILVA LEEDASILVA self-assigned this Apr 19, 2026
@LEEDASILVA LEEDASILVA marked this pull request as ready for review April 20, 2026 17:11
@LEEDASILVA LEEDASILVA force-pushed the integrate-auth-api-to-client branch from b1a0ccb to becc810 Compare April 24, 2026 22:31
@LEEDASILVA
Copy link
Copy Markdown
Collaborator Author

LEEDASILVA commented Apr 26, 2026

This Pr also handles Graphql connection between the front service and the db. It allows us now to query the db with the right role (depending on the user logged in).

front/src/lib
├── auth.ts
├── equipment.ts
├── graphql-client.ts
├── locations.ts
└── utils.ts

1 directory, 5 files

each file indicates the queries and where we can fetch or add them. The graphql-client is basically the connection to the db via graphql engine ofc

@LEEDASILVA LEEDASILVA force-pushed the re-organize-system-to-handle-microservices branch from e667c56 to 9e5c52a Compare April 28, 2026 20:09
@LEEDASILVA LEEDASILVA force-pushed the integrate-auth-api-to-client branch 3 times, most recently from e69cca7 to c8c610e Compare April 30, 2026 21:35
Base automatically changed from re-organize-system-to-handle-microservices to main April 30, 2026 22:05
@LEEDASILVA LEEDASILVA force-pushed the integrate-auth-api-to-client branch from c8c610e to 9e1e790 Compare April 30, 2026 22:06
@LEEDASILVA
Copy link
Copy Markdown
Collaborator Author

new pages for magic link:
image

image image

Once clicked the user would receive email, this would be later on but you can see on the logs the link that we would click:

operafix_api  | FOR TESTING - magic link token: http://localhost:5173/api/auth/magic-link?token=7ad0585d0bb05e1ec78342cafd781b4ae976a77baf84c4343e49c9783e720ad9
image

once validated in 2 seconds we would be redirected to the home page

the link can be clicked again, any error would be displayed on the url:
image

- "/auth/error?reason=missing_token"
- "/auth/error?reason=server_error"
- "/auth/error?reason=invalid_token"

@HarryVasanth HarryVasanth force-pushed the integrate-auth-api-to-client branch from ef91cb1 to f7618b8 Compare May 1, 2026 17:16
@LEEDASILVA LEEDASILVA force-pushed the integrate-auth-api-to-client branch from f7618b8 to 288ac3f Compare May 3, 2026 21:52
LEEDASILVA added 10 commits May 3, 2026 22:52
…er, RoleAdmin) on auth structure to protect other routes when called
…uld be regular integer + fix some issues on the auth route
…query the db using grahpql from the front. Including the token for role permission check

feat(hasura): add permissions roles for all tables
refactor(api): fix some compatability with front
- login page would have an option to login using magic link
- auth verifier for when users click on the magic link from the email
- managing users is only possible with admin role or location manager
- location manager can only manage add users from is own location
- admins are the only ones that can delete/deactivate the user (is_active to false)
- add new field on user table 'is_active' to allow soft delete
- fix sequential id increment when we seed the db
@LEEDASILVA LEEDASILVA force-pushed the integrate-auth-api-to-client branch from 288ac3f to 7b60c7c Compare May 3, 2026 21:52
@LEEDASILVA
Copy link
Copy Markdown
Collaborator Author

added a /user route to manage users:

  • managing users is only possible with admin role or location manager
  • location manager can only manage add users from is own location
  • admins are the only ones that can delete/deactivate the user (is_active to false)
  • add new field on user table 'is_active' to allow soft delete
  • fix sequential id increment when we seed the db
  • creating users is also restricted from admin to location manager, location manager can only add employees or technicians not other roles, meanwhile admins can do whatever they want (except delete other admins)
Screenshot_03-May_22-55-50_15668 image

@LEEDASILVA
Copy link
Copy Markdown
Collaborator Author

LEEDASILVA commented May 9, 2026

Added a way for the graphql requests/queries work with PWA offline! it allows the user to use the application even offline so queries would be cached for a while then refreshed once they have internet. This would allow them to submit issues of equipments even offline and it would be pushed once online.

For this had to add a schema.json with the graphql schema that would allow a better caching keys system. This was generated using npx -y get-graphql-schema -j -h "x-hasura-admin-secret=<sercrete>" http://localhost:8080/v1/graphql > src/lib/gql/schema.json

we should probably create a workflow to check if schema.json is updated compared to our database schema?

- name: Verify GraphQL schema is up to date
  run: |
    docker compose up -d postgres hasura
    npx -y get-graphql-schema -j -h "x-hasura-admin-secret=<sercrete>" http://localhost:8080/v1/graphql > src/lib/gql/schema.json
    git diff --exit-code src/lib/gql/schema.json \
      || (echo "Run 'npm run gql:introspect' and commit the result." && exit 1)

or should we add the npx -y get-graphql-schema -j -h "x-hasura-admin-secret=pNZxIfzAD43hka0HrR02JAmsZmLU10bI" http://localhost:8080/v1/graphql > src/lib/gql/schema.json to the package.json

{
  "scripts": {
    "gql:generate": "@urql/introspect-schema --header \"x-hasura-admin-secret=$HASURA_ADMIN_SECRET\" $VITE_GRAPHQL_URL --output src/lib/gql/schema.json",
    "gql:check": "git diff --exit-code src/lib/gql/schema.json"
  }
}

then we can just call it like this:

- name: Verify GraphQL schema is up to date
  run: |
    docker compose up -d postgres hasura
    npm run gql:generate
    git diff --exit-code src/lib/gql/schema.json \
      || (echo "Run 'npm run gql:introspect' and commit the result." && exit 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant