Skip to content

Commit

Permalink
Merge pull request #40 from KreativeThinker/master
Browse files Browse the repository at this point in the history
chore: update exception handling
  • Loading branch information
KreativeThinker authored Sep 11, 2024
2 parents d3a8942 + 2747143 commit 5f47515
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pwncore/routes/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from logging import getLogger

import jwt
from fastapi import APIRouter, Header, Response, HTTPException, Depends
from fastapi import APIRouter, Depends, Header, HTTPException, Response
from passlib.hash import bcrypt
from pydantic import BaseModel
from tortoise.transactions import atomic

from pwncore.models import Team, User
from pwncore.config import config
from pwncore.models import Team, User

# Metadata at the top for instant accessibility
metadata = {
Expand Down Expand Up @@ -117,8 +117,8 @@ def get_jwt(*, authorization: t.Annotated[str, Header()]) -> JwtInfo:
decoded_token: JwtInfo = jwt.decode(
token, config.jwt_secret, algorithms=["HS256"]
)
except Exception as err: # Will filter for invalid signature/expired tokens
logger.warning("Invalid login", exc_info=err)
except jwt.exceptions.InvalidTokenError as err:
logger.warning("Invalid token", exc_info=err)
raise HTTPException(status_code=401)
return decoded_token

Expand Down

0 comments on commit 5f47515

Please sign in to comment.