From 8f42b708cd13bf94105f1d31aa4f23fbdacc066a Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 27 Jan 2020 13:22:04 +0100 Subject: [PATCH] franceconnect: add scopes setting (#39286) --- hobo/franceconnect/forms.py | 18 ++++++++++++++++++ hobo/franceconnect/views.py | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/hobo/franceconnect/forms.py b/hobo/franceconnect/forms.py index 6ed5d98..9a6889a 100644 --- a/hobo/franceconnect/forms.py +++ b/hobo/franceconnect/forms.py @@ -33,6 +33,24 @@ class SettingsForm(forms.Form): client_secret = forms.CharField( label=_('Client Secret'), widget=forms.TextInput(attrs={'size': 64})) + scopes = forms.MultipleChoiceField( + label=_('Scopes'), + choices=[ + ('given_name', _('given name')), + ('gender', _('gender')), + ('birthdate', _('birthdate')), + ('birthcountry', _('birthcountry')), + ('birthplace', _('birthplace')), + ('family_name', _('family name')), + ('email', _('email')), + ('preferred_username', _('usual family name')), + ('address', _('address')), + ('phone', _('phone')), + ('identite_pivot', _('identite_pivot')), + ('profile', _('profile')), + ('birth', _('birth profile')), + ], + widget=forms.CheckboxSelectMultiple) class EnableForm(forms.Form): diff --git a/hobo/franceconnect/views.py b/hobo/franceconnect/views.py index 9bf7dff..4e60724 100644 --- a/hobo/franceconnect/views.py +++ b/hobo/franceconnect/views.py @@ -60,6 +60,7 @@ class HomeView(FormView): initial['client_id'] = get_variable('A2_FC_CLIENT_ID').value initial['client_secret'] = get_variable('A2_FC_CLIENT_SECRET').value + initial['scopes'] = get_variable('A2_FC_SCOPES').json or ['profile'] return initial @@ -102,6 +103,9 @@ class HomeView(FormView): }, 'email': 'email', }) + + variable = get_variable('A2_FC_SCOPES') + variable.json = form.cleaned_data['scopes'] variable.save() return super(HomeView, self).form_valid(form) -- 2.24.0