Update get User & Refresh Token

This commit is contained in:
2025-06-27 21:58:51 +07:00
parent 8873095102
commit 64b1771e2f
7 changed files with 127 additions and 10 deletions
+10
View File
@@ -19,3 +19,13 @@ func GenerateJWT(userID uint, role string) (string, error) {
// INI PALING PENTING ⬇️
return token.SignedString([]byte(config.GetConfig().JWTSecret))
}
func GenerateRefreshToken(userID uint) (string, error) {
claims := jwt.MapClaims{
"user_id": userID,
"exp": time.Now().Add(time.Hour * 24).Unix(),
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return token.SignedString([]byte(config.GetConfig().JWTSecret))
}