show change password link after user unlink (fixes #32953)

This commit is contained in:
Benjamin Dauvergne 2019-05-16 18:13:18 +02:00
parent 2da033c409
commit d4fd7173eb
2 changed files with 17 additions and 3 deletions

View File

@ -90,9 +90,10 @@ class AppConfig(django.apps.AppConfig):
return None
def a2_hook_user_can_change_password(self, user, request, **kwargs):
for authentication_event in get_authentication_events(request=request):
if authentication_event['how'] == 'france-connect':
return False
if 'fc_id_token' in request.session:
for authentication_event in get_authentication_events(request=request):
if authentication_event['how'] == 'france-connect':
return False
return True

View File

@ -575,3 +575,16 @@ def test_can_change_password(app, fc_settings, caplog, hooks):
assert path(response['Location']) == '/accounts/'
response = response.follow()
assert len(response.pyquery('[href*="password/change"]')) == 0
# Unlink
response = response.click('Delete link')
response.form.set('new_password1', 'ikKL1234')
response.form.set('new_password2', 'ikKL1234')
response = response.form.submit(name='unlink')
continue_url = response.pyquery('a#a2-continue').attr['href']
state = urlparse.parse_qs(urlparse.urlparse(continue_url).query)['state'][0]
assert app.session['fc_states'][state]['next'] == '/accounts/'
response = app.get(reverse('fc-logout') + '?state=' + state)
assert path(response['Location']) == '/accounts/'
response = response.follow()
assert len(response.pyquery('[href*="password/change"]')) > 0