Ajout d'une route pour vérifier le JWT de l'utilisateur

This commit is contained in:
Nabil Ould Hamou 2024-03-01 00:46:18 +01:00
parent 58444a3c3e
commit fd3c48d418
No known key found for this signature in database
GPG key ID: 2B1AE73E9B6014EF
2 changed files with 5 additions and 0 deletions

View file

@ -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,

View file

@ -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)