Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import jwt
|
||||
from fastapi import Header, status, HTTPException
|
||||
|
||||
from backend.code.services.token import TokenService
|
||||
|
||||
class PrivateMiddleware:
|
||||
def __init__(self):
|
||||
self._tokenService = TokenService()
|
||||
|
||||
def HasToken(self, token: str = Header(...)):
|
||||
if token is None:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
|
||||
|
||||
if self._tokenService.ValidateToken(token) == False:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
|
||||
|
||||
return token
|
||||
|
||||
|
||||
Reference in New Issue
Block a user