Initial commit

This commit is contained in:
Mann Patel
2025-08-26 14:13:09 -06:00
commit 23f6b359ca
39 changed files with 4606 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package models
import (
"fmt"
"github.com/golang-jwt/jwt/v5"
)
var jwtKey = []byte("your-secret-key") //TODO: Move to env/config
func ExtractClaims(tokenStr string) (*Claims, error) {
claims := &Claims{}
token, err := jwt.ParseWithClaims(tokenStr, claims, func(token *jwt.Token) (interface{}, error) {
return jwtKey, nil
})
if err != nil {
return nil, err
}
if !token.Valid {
return nil, fmt.Errorf("invalid token")
}
return claims, nil
}