Skip to content

Commit

Permalink
Added auth to user routes
Browse files Browse the repository at this point in the history
  • Loading branch information
p0t4t0sandwich committed Apr 29, 2024
1 parent 4bba3ab commit dcf01fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

mw "github.com/NeuralNexusDev/neuralnexus-api/middleware"
authroutes "github.com/NeuralNexusDev/neuralnexus-api/modules/auth/routes"
"github.com/NeuralNexusDev/neuralnexus-api/modules/auth/users"
beenamegenerator "github.com/NeuralNexusDev/neuralnexus-api/modules/bee_name_generator"
"github.com/NeuralNexusDev/neuralnexus-api/modules/datastore"
numbersds "github.com/NeuralNexusDev/neuralnexus-api/modules/datastore/numbers"
Expand Down Expand Up @@ -55,6 +56,7 @@ func (s *APIServer) Setup() http.Handler {
projects.ApplyRoutes,
switchboard.ApplyRoutes,
teapot.ApplyRoutes,
users.ApplyRoutes,
)

middlewareStack := mw.CreateStack(
Expand Down
9 changes: 5 additions & 4 deletions modules/auth/users/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package users
import (
"net/http"

mw "github.com/NeuralNexusDev/neuralnexus-api/middleware"
"github.com/NeuralNexusDev/neuralnexus-api/modules/auth"
accountlinking "github.com/NeuralNexusDev/neuralnexus-api/modules/auth/linking"
"github.com/NeuralNexusDev/neuralnexus-api/modules/database"
Expand All @@ -13,10 +14,10 @@ import (
func ApplyRoutes(mux *http.ServeMux) *http.ServeMux {
db := database.GetDB("neuralnexus")
service := NewService(auth.NewAccountStore(db), accountlinking.NewStore(db))
mux.HandleFunc("GET /api/v1/users/{user_id}", GetUserHandler(service))
mux.HandleFunc("PUT /api/v1/users/{user_id}", UpdateUserHandler(service))
mux.HandleFunc("PUT /api/v1/users/{platform}/{platform_id}", UpdateUserFromPlatformHandler(service))
mux.HandleFunc("DELETE /api/v1/users/{user_id}", DeleteUserHandler(service))
mux.HandleFunc("GET /api/v1/users/{user_id}", mw.Auth(GetUserHandler(service)))
mux.HandleFunc("PUT /api/v1/users/{user_id}", mw.Auth(UpdateUserHandler(service)))
mux.HandleFunc("PUT /api/v1/users/{platform}/{platform_id}", mw.Auth(UpdateUserFromPlatformHandler(service)))
mux.HandleFunc("DELETE /api/v1/users/{user_id}", mw.Auth(DeleteUserHandler(service)))
return mux
}

Expand Down

0 comments on commit dcf01fe

Please sign in to comment.