Send <!doctype html> in responses when auth fails

このコミットが含まれているのは:
n9k 2022-03-15 10:24:59 +00:00
コミット 95f12fa632
1個のファイルの変更14行の追加7行の削除

ファイルの表示

@ -33,13 +33,20 @@ def auth_required(f):
async def wrapper(*args, **kwargs): async def wrapper(*args, **kwargs):
if check_auth(request): if check_auth(request):
return await f(*args, **kwargs) return await f(*args, **kwargs)
hint = 'The broadcaster should log in with the credentials printed ' \ hint = (
'in their terminal.' 'The broadcaster should log in with the credentials printed in '
'their terminal.'
)
if request.authorization is None:
body = ( body = (
f'<p>{hint}</p>' f'<!doctype html>\n'
if request.authorization is None else f'<p>{hint}</p>\n'
'<p>Wrong username or password. Refresh the page to try again.</p>' )
f'<p>{hint}</p>' else:
body = (
f'<!doctype html>\n'
f'<p>Wrong username or password. Refresh the page to try again.</p>\n'
f'<p>{hint}</p>\n'
) )
return body, 401, {'WWW-Authenticate': 'Basic'} return body, 401, {'WWW-Authenticate': 'Basic'}