show change password link after user unlink (fixes #32953)
This commit is contained in:
parent
2da033c409
commit
d4fd7173eb
|
@ -90,9 +90,10 @@ class AppConfig(django.apps.AppConfig):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def a2_hook_user_can_change_password(self, user, request, **kwargs):
|
def a2_hook_user_can_change_password(self, user, request, **kwargs):
|
||||||
for authentication_event in get_authentication_events(request=request):
|
if 'fc_id_token' in request.session:
|
||||||
if authentication_event['how'] == 'france-connect':
|
for authentication_event in get_authentication_events(request=request):
|
||||||
return False
|
if authentication_event['how'] == 'france-connect':
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -575,3 +575,16 @@ def test_can_change_password(app, fc_settings, caplog, hooks):
|
||||||
assert path(response['Location']) == '/accounts/'
|
assert path(response['Location']) == '/accounts/'
|
||||||
response = response.follow()
|
response = response.follow()
|
||||||
assert len(response.pyquery('[href*="password/change"]')) == 0
|
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
|
||||||
|
|
Reference in New Issue