chore(api/libs): Apply ruff format. (#7301)

This commit is contained in:
-LAN- 2024-08-15 17:53:12 +08:00 • committed by GitHub
commit 9414143b5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 270 additions and 320 deletions

View file

@ -9,14 +9,14 @@ class PassportService:
self.sk = dify_config.SECRET_KEY
def issue(self, payload):
return jwt.encode(payload, self.sk, algorithm='HS256')
return jwt.encode(payload, self.sk, algorithm="HS256")
def verify(self, token):
try:
return jwt.decode(token, self.sk, algorithms=['HS256'])
return jwt.decode(token, self.sk, algorithms=["HS256"])
except jwt.exceptions.InvalidSignatureError:
raise Unauthorized('Invalid token signature.')
raise Unauthorized("Invalid token signature.")
except jwt.exceptions.DecodeError:
raise Unauthorized('Invalid token.')
raise Unauthorized("Invalid token.")
except jwt.exceptions.ExpiredSignatureError:
raise Unauthorized('Token has expired.')
raise Unauthorized("Token has expired.")