mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-31 22:59:55 +00:00
change logging module imports
This commit is contained in:
@ -17,10 +17,11 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import logging
|
||||
|
||||
from aiohttp.web import middleware, Request
|
||||
from aiohttp.web_exceptions import HTTPClientError, HTTPException, HTTPServerError
|
||||
from aiohttp.web_response import json_response, StreamResponse
|
||||
from logging import Logger
|
||||
|
||||
from ahriman.web.middlewares import HandlerType, MiddlewareType
|
||||
|
||||
@ -28,12 +29,12 @@ from ahriman.web.middlewares import HandlerType, MiddlewareType
|
||||
__all__ = ["exception_handler"]
|
||||
|
||||
|
||||
def exception_handler(logger: Logger) -> MiddlewareType:
|
||||
def exception_handler(logger: logging.Logger) -> MiddlewareType:
|
||||
"""
|
||||
exception handler middleware. Just log any exception (except for client ones)
|
||||
|
||||
Args:
|
||||
logger(Logger): class logger
|
||||
logger(logging.Logger): class logger
|
||||
|
||||
Returns:
|
||||
MiddlewareType: built middleware
|
||||
|
@ -18,6 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp.web import HTTPFound
|
||||
from aiohttp.web_exceptions import HTTPUnauthorized
|
||||
|
||||
from ahriman.core.auth.helpers import check_authorized, forget
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@ -41,7 +42,10 @@ class LogoutView(BaseView):
|
||||
Raises:
|
||||
HTTPFound: on success response
|
||||
"""
|
||||
await check_authorized(self.request)
|
||||
try:
|
||||
await check_authorized(self.request)
|
||||
except HTTPUnauthorized:
|
||||
raise HTTPUnauthorized(reason="I'm a teapot")
|
||||
await forget(self.request, HTTPFound("/"))
|
||||
|
||||
raise HTTPFound("/")
|
||||
|
Reference in New Issue
Block a user