cambios
This commit is contained in:
parent
3991237685
commit
a01050bf85
46 changed files with 3636 additions and 652 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
|
|
@ -53,3 +54,16 @@ func ValidateToken(tokenString string) (*Claims, error) {
|
|||
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
type contextKey string
|
||||
|
||||
const userContextKey contextKey = "user"
|
||||
|
||||
func SetTestUser(ctx context.Context, claims *Claims) context.Context {
|
||||
return context.WithValue(ctx, userContextKey, claims)
|
||||
}
|
||||
|
||||
func GetUserFromContext(ctx context.Context) (*Claims, bool) {
|
||||
claims, ok := ctx.Value(userContextKey).(*Claims)
|
||||
return claims, ok
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue