crafty-4/app/classes/web/routes/api/auth/invalidate_tokens.py
luukas 2aa2d14f5e
Improve the invalidate tokens API handler
* Remove the TODO
* Replace the Console.info with logger.debug
2022-05-25 00:35:11 +03:00

20 lines
564 B
Python

import datetime
import logging
from app.classes.web.base_api_handler import BaseApiHandler
logger = logging.getLogger(__name__)
class ApiAuthInvalidateTokensHandler(BaseApiHandler):
def post(self):
auth_data = self.authenticate_user()
if not auth_data:
return
logger.debug(f"Invalidate tokens for user {auth_data[4]['user_id']}")
self.controller.users.raw_update_user(
auth_data[4]["user_id"], {"valid_tokens_from": datetime.datetime.now()}
)
self.finish_json(200, {"status": "ok"})