fix: allow registration only if authenticated
This commit is contained in:
+1
-1
@@ -117,13 +117,13 @@ func main() {
|
|||||||
r.GET("/health", h.Health)
|
r.GET("/health", h.Health)
|
||||||
r.GET("/hello", h.Hello)
|
r.GET("/hello", h.Hello)
|
||||||
r.POST("/login", h.Login)
|
r.POST("/login", h.Login)
|
||||||
r.POST("/register", h.Register)
|
|
||||||
r.GET("/devices", h.GetDevices)
|
r.GET("/devices", h.GetDevices)
|
||||||
|
|
||||||
// mqttping endpoint handled by internal/handler (protected)
|
// mqttping endpoint handled by internal/handler (protected)
|
||||||
|
|
||||||
// Protected routes
|
// Protected routes
|
||||||
auth := r.Group("/")
|
auth := r.Group("/")
|
||||||
|
auth.POST("/register", h.Register)
|
||||||
auth.Use(middleware.AuthMiddleware(cfg.Server.JWTSecret))
|
auth.Use(middleware.AuthMiddleware(cfg.Server.JWTSecret))
|
||||||
auth.GET("/protected", h.Protected)
|
auth.GET("/protected", h.Protected)
|
||||||
auth.GET("/mqttping", h.MQTTPing)
|
auth.GET("/mqttping", h.MQTTPing)
|
||||||
|
|||||||
Reference in New Issue
Block a user