rase 405 error in case if GET login method is used whereas no aioauth

library installed
This commit is contained in:
2023-07-23 02:52:32 +03:00
parent c7de182f3d
commit 9cb39f6767
4 changed files with 46 additions and 1 deletions

View File

@ -64,7 +64,11 @@ class LoginView(BaseView):
HTTPMethodNotAllowed: in case if method is used, but OAuth is disabled
HTTPUnauthorized: if case of authorization error
"""
from ahriman.core.auth.oauth import OAuth
try:
from ahriman.core.auth.oauth import OAuth
except ImportError:
# no aioauth library found
raise HTTPMethodNotAllowed(self.request.method, ["POST"])
oauth_provider = self.validator
if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway