manager: add sidebar info on users linked to FC (#27392)
This commit is contained in:
parent
6c4128e68b
commit
4baa839294
|
@ -18,6 +18,7 @@ from . import app_settings
|
|||
|
||||
|
||||
import django.apps
|
||||
from django import template
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
|
@ -53,6 +54,10 @@ class AppConfig(django.apps.AppConfig):
|
|||
serializer.get_franceconnect = get_franceconnect
|
||||
serializer.fields['franceconnect'] = serializers.SerializerMethodField()
|
||||
|
||||
def a2_hook_manager_user_data(self, view, user):
|
||||
context = {'user': user}
|
||||
return [template.loader.get_template('authentic2_auth_fc/manager_user_sidebar.html').render(context)]
|
||||
|
||||
def a2_hook_user_can_reset_password(self, user):
|
||||
if user.fc_accounts.exists():
|
||||
return True
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% for account in user.fc_accounts.all %}
|
||||
<div class="auth-fc-user-sidebar">
|
||||
<p>{% trans "Link with FranceConnect created on" %} {{ account.created }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
|
@ -35,6 +35,8 @@ from django.utils.timezone import now
|
|||
from authentic2_auth_fc import models
|
||||
from authentic2_auth_fc.utils import requests_retry_session
|
||||
|
||||
from ..utils import login
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
@ -655,3 +657,15 @@ def test_can_change_password(app, fc_settings, caplog, hooks):
|
|||
|
||||
def test_invalid_next_url(app, fc_settings, caplog, hooks):
|
||||
assert app.get('/fc/callback/?code=coin&next=JJJ72QQQ').location == 'JJJ72QQQ'
|
||||
|
||||
|
||||
def test_manager_user_sidebar(app, fc_settings, superuser, simple_user):
|
||||
login(app, superuser, '/manage/')
|
||||
response = app.get('/manage/users/%s/' % simple_user.id)
|
||||
assert 'FranceConnect' not in response
|
||||
|
||||
fc_account = models.FcAccount(user=simple_user)
|
||||
fc_account.save()
|
||||
|
||||
response = app.get('/manage/users/%s/' % simple_user.id)
|
||||
assert 'FranceConnect' in response
|
||||
|
|
Loading…
Reference in New Issue