From fd3c48d4184b8484792ddb7d596e059dde5dd87e Mon Sep 17 00:00:00 2001 From: Nabil Ould Hamou Date: Fri, 1 Mar 2024 00:46:18 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20route=20pour=20v=C3=A9rifier=20?= =?UTF-8?q?le=20JWT=20de=20l'utilisateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/authController.go | 4 ++++ main.go | 1 + 2 files changed, 5 insertions(+) diff --git a/controllers/authController.go b/controllers/authController.go index 568d0ef..e2a4442 100644 --- a/controllers/authController.go +++ b/controllers/authController.go @@ -114,6 +114,10 @@ func Login(c *gin.Context) { }) } +func ValidateToken(c *gin.Context) { + c.AbortWithStatus(http.StatusAccepted) +} + func createToken(userId uuid.UUID) (string, error) { token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ "bearer": userId, diff --git a/main.go b/main.go index 7442b06..41b08c2 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ func main() { // Auth api.Api.POST("/signup", controllers.Signup) api.Api.POST("/login", controllers.Login) + api.Api.GET("/validate", middleware.RequireAuth, controllers.ValidateToken) // Users api.Api.GET("/users", controllers.GetUsers)