misc: show service name only if it's OIDC service (#64467)
This commit is contained in:
parent
1a6532cd46
commit
28b2278aae
|
@ -18,7 +18,6 @@ from django.conf import settings
|
|||
from pkg_resources import get_distribution
|
||||
|
||||
from . import app_settings, constants
|
||||
from .models import Service
|
||||
from .utils import misc as utils_misc
|
||||
from .utils.service import get_home_url, get_service
|
||||
|
||||
|
@ -64,20 +63,19 @@ def a2_processor(request):
|
|||
if hasattr(request, 'session'):
|
||||
variables['LAST_LOGIN'] = request.session.get(constants.LAST_LOGIN_SESSION_KEY)
|
||||
variables['USER_SWITCHED'] = constants.SWITCH_USER_SESSION_KEY in request.session
|
||||
if 'service_pk' in request.session:
|
||||
try:
|
||||
service = Service.objects.get(pk=request.session['service_pk'])
|
||||
variables['service'] = service
|
||||
variables['service_colour'] = service.colour
|
||||
if service.logo:
|
||||
variables['service_logo_url'] = service.logo.url
|
||||
if service.ou:
|
||||
variables['service_ou_colour'] = service.ou.colour
|
||||
if service.ou.logo:
|
||||
variables['service_ou_logo_url'] = service.ou.logo.url
|
||||
service = get_service(request)
|
||||
if service:
|
||||
variables['service'] = service
|
||||
variables['service_colour'] = service.colour
|
||||
# name and logo should be show for OIDC service only
|
||||
variables['show_service_infos'] = type(service).__name__ != 'LibertyProvider'
|
||||
|
||||
except Service.DoesNotExist:
|
||||
pass
|
||||
if service.logo:
|
||||
variables['service_logo_url'] = service.logo.url
|
||||
if service.ou:
|
||||
variables['service_ou_colour'] = service.ou.colour
|
||||
if service.ou.logo:
|
||||
variables['service_ou_logo_url'] = service.ou.logo.url
|
||||
return variables
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{% firstof service.home_url service.ou.home_url as home_url %}
|
||||
{% firstof service.name service.ou.name as name %}
|
||||
|
||||
{% if home_url %}
|
||||
{% if show_service_infos and home_url %}
|
||||
{% block service-colour %}
|
||||
{% if colour %}
|
||||
<style>
|
||||
|
|
|
@ -156,7 +156,6 @@ def test_login_from_client_with_home_url(oidc_client, app):
|
|||
assert response.pyquery.find('a.service-message--link')
|
||||
link = response.pyquery.find('a.service-message--link')[0]
|
||||
assert link.attrib['href'] == 'https://ou.example.net'
|
||||
print(response.text)
|
||||
assert 'color: #8c00ec' in response.text
|
||||
assert (
|
||||
response.pyquery.find('img.service-message--logo')[0].attrib['src']
|
||||
|
|
Loading…
Reference in New Issue