Skip to content

Commit

Permalink
fix: early return when token expires
Browse files Browse the repository at this point in the history
  • Loading branch information
brian030128 committed Jun 24, 2024
1 parent 8b2851c commit 14e75db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/auth/auth_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func validateBearerToken(token string, secret string) (uuid.UUID, error) {
token, err := jwt.ParseWithClaims(tokenStr, &jwt.RegisteredClaims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(secret), nil
})
if err != nil {
return uuid.Nil, err
}
if claims, ok := token.Claims.(*jwt.RegisteredClaims); ok {
userId, err := uuid.Parse(claims.Subject)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion services/api/controllers/group/generate_invite_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
inviteCodeChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
inviteCodeChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
timeDeterLength = 4
randomLength = 2
inviteCodeLength = timeDeterLength + randomLength
Expand Down

0 comments on commit 14e75db

Please sign in to comment.