Send <!doctype html> in responses when auth fails
このコミットが含まれているのは:
コミット
95f12fa632
|
@ -33,14 +33,21 @@ 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 '
|
||||||
body = (
|
'their terminal.'
|
||||||
f'<p>{hint}</p>'
|
|
||||||
if request.authorization is None else
|
|
||||||
'<p>Wrong username or password. Refresh the page to try again.</p>'
|
|
||||||
f'<p>{hint}</p>'
|
|
||||||
)
|
)
|
||||||
|
if request.authorization is None:
|
||||||
|
body = (
|
||||||
|
f'<!doctype html>\n'
|
||||||
|
f'<p>{hint}</p>\n'
|
||||||
|
)
|
||||||
|
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'}
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
読み込み中…
新しいイシューから参照