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