auth_fc: record user registration events (#64339)
This commit is contained in:
parent
86eaa87f4b
commit
7855147ac4
|
@ -433,6 +433,9 @@ class LoginOrLinkView(View):
|
|||
if created:
|
||||
logger.info('auth_fc: new account "%s" created with FranceConnect sub "%s"', user, sub)
|
||||
hooks.call_hooks('event', name='fc-create', user=user, sub=sub, request=request)
|
||||
# FC account creation does not rely on the registration_completion generic view.
|
||||
# Registration event has to be recorded here:
|
||||
request.journal.record('user.registration', user=user, how='france-connect')
|
||||
else:
|
||||
logger.info('auth_fc: existing account "%s" linked to FranceConnect sub "%s"', user, sub)
|
||||
hooks.call_hooks('event', name='fc-link', user=user, sub=sub, request=request)
|
||||
|
|
|
@ -103,10 +103,13 @@ def test_create(settings, app, franceconnect, hooks, service):
|
|||
response = franceconnect.handle_authorization(app, response.location, status=302)
|
||||
assert 'fc-state' not in app.cookies
|
||||
assert User.objects.count() == 1
|
||||
# check login for service=portail was registered
|
||||
assert Event.objects.which_references(service).count() == 1
|
||||
|
||||
user = User.objects.get()
|
||||
# check login for service=portail and user registration were registered
|
||||
assert Event.objects.which_references(service).count() == 2
|
||||
assert (
|
||||
Event.objects.filter(type__name='user.registration', user=user).which_references(service).count() == 1
|
||||
)
|
||||
|
||||
assert user.verified_attributes.first_name == 'Ÿuñe'
|
||||
assert user.verified_attributes.last_name == 'Frédérique'
|
||||
assert path(response.location) == '/idp/'
|
||||
|
|
Loading…
Reference in New Issue