Merge pull request #3315 from dtaniwaki/improve-handler

Make Authenticator Custom HTML Flexible
This commit is contained in:
Min RK
2021-02-01 11:42:27 +00:00
committed by GitHub
2 changed files with 22 additions and 8 deletions

View File

@@ -1101,6 +1101,13 @@ class PAMAuthenticator(LocalAuthenticator):
else:
return super().normalize_username(username)
def get_custom_html(self, base_url):
"""Get custom HTML for the authenticator.
.. versionadded: 1.4
"""
return self.custom_html
for _old_name, _new_name, _version in [
("check_group_whitelist", "check_group_allowed", "1.2"),

View File

@@ -3,6 +3,7 @@
# Distributed under the terms of the Modified BSD License.
import asyncio
from jinja2 import Template
from tornado import web
from tornado.escape import url_escape
from tornado.httputil import url_concat
@@ -90,17 +91,23 @@ class LoginHandler(BaseHandler):
"""Render the login page."""
def _render(self, login_error=None, username=None):
return self.render_template(
'login.html',
next=url_escape(self.get_argument('next', default='')),
username=username,
login_error=login_error,
custom_html=self.authenticator.custom_html,
login_url=self.settings['login_url'],
authenticator_login_url=url_concat(
context = {
"next": url_escape(self.get_argument('next', default='')),
"username": username,
"login_error": login_error,
"login_url": self.settings['login_url'],
"authenticator_login_url": url_concat(
self.authenticator.login_url(self.hub.base_url),
{'next': self.get_argument('next', '')},
),
}
custom_html = Template(
self.authenticator.get_custom_html(self.hub.base_url)
).render(**context)
return self.render_template(
'login.html',
**context,
custom_html=custom_html,
)
async def get(self):