Unverified Commit 6925c10a authored by Enrico Zini's avatar Enrico Zini
Browse files

Fixed whoami template. Closes: #4

parents 3731aa30 1f4dea0b
...@@ -2,25 +2,50 @@ ...@@ -2,25 +2,50 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
{% if request.sso_username %} {% if request.signon_identities %}
{% if visitor %} {% if visitor %}
{% blocktrans with request_user_username=request.user.username visitor_a_link=visitor.a_link %}You
are currently logged in with {% blocktrans with visitor_a_link=visitor.a_link %}
<a href="https://wiki.debian.org/DebianSingleSignOn">SSO username</a> You are currently logged in, and recognized as {{visitor_a_link}}.
<b>{{request_user_username}}</b>, and recognized as {{visitor_a_link}}.{% endblocktrans %} {% endblocktrans %}
{% else %} {% else %}
{% url 'dm_claim' as dm_claim_url %} {% url 'dm_claim' as dm_claim_url %}
{% blocktrans with request_user_username=request.user.username %}You {% blocktrans with request_user_username=request.user.username %}You
are currently logged in with are currently logged in, but not mapped to any person in the site.
<a href="https://wiki.debian.org/DebianSingleSignOn">SSO username</a>
<b>{{request_user_username}}</b>, but not mapped to any person in the site.
If you are a Debian Maintainer, you can try to correct the situation using the If you are a Debian Maintainer, you can try to correct the situation using the
<a href="{{dm_claim}}">claim interface</a>.{% endblocktrans %} <a href="{{dm_claim}}">claim interface</a>.{% endblocktrans %}
<p>{% trans "You are logged in as:" %}</p>
<ul>
{% for identity in request.signon_identities.values %}
<li>
{% with identity.get_provider as provider %}
{% if identity.picture %}
<img class="personpic ml-auto" src="{{identity.picture}}"></img>
{% elif provider.icon %}
<img style="vertical-align: text-top; height: 1em" class="mr-2" src="{{STATIC_URL}}{{provider.icon}}"></img>
{% else %}
<span class="mr-2 fa fa-sign-in"></span>
{% endif %} {% endif %}
{% if identity.profile %}<a href="{{identity.profile}}">{% endif %}
{{provider.label}}:
{{identity.fullname}}{% if identity.username %} &lt;{{identity.username}}&gt;{% endif %}
{% if identity.profile %}</a>{% endif %}
{% endwith %}
</li>
{% endfor %}
</ul>
{% endif %}
{% else %} {% else %}
{% blocktrans %}You are not currently logged in. See the {% blocktrans %}You are not currently logged in. See the
<a href="https://wiki.debian.org/DebianSingleSignOn">Single Sign-On page</a> <a href="https://wiki.debian.org/DebianSingleSignOn">Single Sign-On page</a>
for details.{% endblocktrans %} for details.{% endblocktrans %}
{% endif %} {% endif %}
</div> </div>
</div> </div>
...@@ -5,7 +5,7 @@ from backend import const ...@@ -5,7 +5,7 @@ from backend import const
from backend.unittest import PersonFixtureMixin from backend.unittest import PersonFixtureMixin
class PersonPageTestCase(PersonFixtureMixin, TestCase): class AdvocateTests(PersonFixtureMixin, TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super().setUpClass() super().setUpClass()
......
from __future__ import annotations
from django.test import TestCase
from django.urls import reverse
from backend import const
from backend.unittest import PersonFixtureMixin
from signon.models import Identity
class WhoamiTests(PersonFixtureMixin, TestCase):
def test_notlogged(self):
# Check that the new person is listed on the page
client = self.make_test_client(None)
response = client.get(reverse('wizard_home'))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "You are not currently logged in.")
self.assertNotContains(response, "but not mapped to any person in the site.")
self.assertNotContains(response, "You are currently logged in, and recognized as")
def test_active_unbound(self):
# Check that the new person is listed on the page
identity = Identity.objects.create(
issuer="debsso", subject="test@debian.org",
username="test@debian.org", audit_skip=True)
client = self.make_test_client(None, [identity])
response = client.get(reverse('wizard_home'))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "You are not currently logged in.")
self.assertContains(response, "but not mapped to any person in the site.")
self.assertNotContains(response, "You are currently logged in, and recognized as")
def test_active_bound(self):
# Check that the new person is listed on the page
identity = Identity.objects.create(
person=self.persons.dc,
issuer="debsso", subject="test@debian.org",
username="test@debian.org", audit_skip=True)
client = self.make_test_client(self.persons.dc, [identity])
response = client.get(reverse('wizard_home'))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "You are not currently logged in.")
self.assertNotContains(response, "but not mapped to any person in the site.")
self.assertContains(response, "You are currently logged in, and recognized as")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment