Skip to content

Commit

Permalink
Add next-auth (#707)
Browse files Browse the repository at this point in the history
* Add next-auth to project

* Remove react-oidc-context

* Add protected Route middleware

* Create SignIn page

* Replace Axios with js Fetch api on apiClient

This change was done to cache the data, nexjs automatically caches the
data that comes with the fetch api.

* Replace the taskform client api calls to server-side api calls

* Update .env.example on /frontend

* Add loading state to TaskForm

* Move data fetching functions to its proper place

* Fix middleware invalid accessToken

* Remove protectedRoutes

Now all routes are protected by default

* Revert middleware to previous configuration

next-auth default middleware had an issue of not redirecting the
user if they weren't logged in, so I decided to revert to the manual
configuration that we had before

* Refactor apiClient to make it usable by client and server components

Now the api interaction functions will receive an apiClient that can
be a server side apiClient or client side apiClient, that allows for
more flexibility, to be able to call the api from anywhere using
the same functions.

* Adjust form submission to work with client side apiClient

* Add next_public_base_api to .env

* Fix TaskForm spec

* Fix failed task creation not showing error toast
  • Loading branch information
negreirosleo authored Oct 20, 2023
1 parent d9aab1a commit 35d3002
Show file tree
Hide file tree
Showing 36 changed files with 577 additions and 438 deletions.
17 changes: 9 additions & 8 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
NEXT_PUBLIC_OIDC_AUTHORITY=
NEXT_PUBLIC_OIDC_CLIENT_ID=
NEXT_PUBLIC_OIDC_CLIENT_SECRET=
NEXT_PUBLIC_OIDC_REDIRECT_URL=
NEXT_PUBLIC_OIDC_METADATA_URL=
NEXT_PUBLIC_OIDC_RESPONSE_TYPE=
NEXT_PUBLIC_API_BASE='http://localhost:8555'
NEXT_PUBLIC_OIDC_USERNAME_PROPERTY='preferred_username'
OIDC_AUTHORITY=
OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET=

API_BASE='http://phpreport-api:8555'
NEXT_PUBLIC_API_BASE='http://0.0.0.0:8555'

NEXTAUTH_URL=http://0.0.0.0:5173/web/v2/api/auth
NEXTAUTH_SECRET=""
Loading

0 comments on commit 35d3002

Please sign in to comment.