docs: def bernard_auth(func):
      """
      Authenticates the users based on the query-string-provided token
      """
  
      @wraps(func)
      async def wrapper(request: Request):
          def get_query_token():
              token_key = settings.WEBVIEW_TOKEN_KEY
              return request.query.get(token_key, '')
  
          def get_header_token():
              header_key = settings.WEBVIEW_HEADER_NAME
              return request.headers.get(header_key, '')
  
          try:
              token = next(filter(None, [
                  get_header_token(),
                  get_query_token(),
              ]))
          except StopIteration:
              token = ''
  
          try:
              body = await request.json()
          except ValueError:
              body = None
  
          msg, platform = await manager.message_from_token(token, body)
  
          if not msg:
              return json_response({
                  'status': 'unauthorized',
                  'message': 'No valid token found',
              }, status=401)
  
          return await func(msg, platform)
      return wrapper