mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
Merge pull request #3315 from dtaniwaki/improve-handler
Make Authenticator Custom HTML Flexible
This commit is contained in:
@@ -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"),
|
||||
|
@@ -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):
|
||||
|
Reference in New Issue
Block a user