A multipurpose python flask API server and administration SPA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
756 B

  1. """User API blueprint and endpoint definitions."""
  2. from flask import Blueprint, abort
  3. from corvus.api.decorators import return_json
  4. from corvus.api.model import APIResponse
  5. from corvus.middleware import authentication_middleware
  6. from corvus.service import user_service
  7. USER_BLUEPRINT = Blueprint(
  8. name='user', import_name=__name__, url_prefix='/user')
  9. @USER_BLUEPRINT.route('/<name>', methods=['GET'])
  10. @return_json
  11. @authentication_middleware.require_token_auth
  12. def get_user(name: str) -> APIResponse:
  13. """
  14. Get a token for continued authentication.
  15. :return: A login token for continued authentication
  16. """
  17. user = user_service.find_by_name(name)
  18. if user is not None:
  19. return APIResponse(user, 200)
  20. return abort(404)