Merge branch 'thubrecht/connexion_vieux' into 'master'

Thubrecht/connexion vieux

See merge request klub-dev-ens/authens!26
This commit is contained in:
Martin Pepin 2021-01-28 20:41:15 +01:00
commit 82b2662636
4 changed files with 51 additions and 14 deletions

View file

@ -148,10 +148,16 @@ class OldCASBackend:
return return
try: try:
old_cas_acc = OldCASAccount.objects.get( try:
cas_login=cas_login, entrance_year=entrance_year cas_acc = CASAccount.objects.get(
) cas_login=cas_login, entrance_year=entrance_year
user = old_cas_acc.user )
user = cas_acc.user
except CASAccount.DoesNotExist:
old_cas_acc = OldCASAccount.objects.get(
cas_login=cas_login, entrance_year=entrance_year
)
user = old_cas_acc.user
except OldCASAccount.DoesNotExist: except OldCASAccount.DoesNotExist:
# As in Django's ModelBackend, we run the password hasher once # As in Django's ModelBackend, we run the password hasher once
# to mitigate timing attacks # to mitigate timing attacks

View file

@ -37,6 +37,22 @@ html, body {
flex-flow: row wrap; flex-flow: row wrap;
} }
#container-footer {
width: 100%;
background: #505160;
color: white;
}
#container-footer p {
padding: 5px;
font-weight: initial;
font-size: 1em;
margin: 0;
}
#container-footer a {
color: white;
}
/* /*
Background color definitions Background color definitions
*/ */

View file

@ -7,16 +7,22 @@
{% block content %} {% block content %}
<div id="container-content"> <div id="container-content">
<a class="big-button cas" href="{% url "authens:login.cas" %}?next={{ next| urlencode }}"> <a class="big-button cas" href="{% url "authens:login.cas" %}?next={{ next| urlencode }}">
{% trans "Clipper" %} {% trans "Clipper" %}
</a>
<a class="big-button exte" href="{% url "authens:login.pwd" %}?next={{ next| urlencode }}">
{% trans "Mot de passe" %}
</a>
{% if oldcas %}
<a class="big-button oldcas" href="{% url "authens:login.oldcas" %}?next={{ next| urlencode }}">
{% trans "Vieilleux" %}
</a> </a>
{% endif %} <a class="big-button exte" href="{% url "authens:login.pwd" %}?next={{ next| urlencode }}">
{% trans "Mot de passe" %}
</a>
{% if oldcas %}
<a class="big-button oldcas" href="{% url "authens:login.oldcas" %}?next={{ next| urlencode }}">
{% trans "Vieilleux" %}
</a>
{% endif %}
</div> </div>
{% if oldcas %}
<div id="container-footer">
{% url "authens:reset.pwd" as url_reset %}
<p>{% blocktrans %}Si votre fin de scolarité approche, créez un mot de passe pour votre compte pour bénéficier de la connexion vieilleux : <a href="{{ url_reset }}">créer un mot de passe</a>.{% endblocktrans %}</p>
</div>
{% endif %}
{% endblock %} {% endblock %}

View file

@ -123,3 +123,12 @@ class TestOldCASBackend(TestCase):
None, cas_login="johndoe", entrance_year=2014, password="password" None, cas_login="johndoe", entrance_year=2014, password="password"
) )
self.assertEqual(auth_user, user) self.assertEqual(auth_user, user)
def test_not_migrated_auth(self):
user = UserModel.objects.create_user(username="vieilleux", password="password")
CASAccount.objects.create(user=user, cas_login="vieilleux", entrance_year=2015)
auth_user = authenticate(
None, cas_login="vieilleux", entrance_year=2015, password="password"
)
self.assertEqual(auth_user, user)