From 25b3a6635104da546308ceb1e5f912a567e71b87 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 21 Aug 2023 17:08:57 +0200 Subject: [PATCH 1/2] Allow to add more than one OAuth provider --- umap/templates/auth/user_form.html | 25 +++++++++++++++++++++++++ umap/views.py | 8 +++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/umap/templates/auth/user_form.html b/umap/templates/auth/user_form.html index a777854e..c5401399 100644 --- a/umap/templates/auth/user_form.html +++ b/umap/templates/auth/user_form.html @@ -19,5 +19,30 @@ +
+

{% trans "Your current providers" %}

+ +
+
+

{% trans "Connect to another provider" %}

+

+ {% blocktrans %}It's a good habit to connect your account to more than one provider, in case one provider becomes unavailable, temporarily or even permanently.{% endblocktrans %} +

+
+ +
+
{% endblock maincontent %} diff --git a/umap/views.py b/umap/views.py index e3acfe63..6e6b905e 100644 --- a/umap/views.py +++ b/umap/views.py @@ -168,11 +168,17 @@ about = About.as_view() class UserProfile(UpdateView): model = User form_class = UserProfileForm - success_url = reverse_lazy('user_profile') + success_url = reverse_lazy("user_profile") def get_object(self): return self.get_queryset().get(pk=self.request.user.pk) + def get_context_data(self, **kwargs): + kwargs.update( + {"providers": self.object.social_auth.values_list("provider", flat=True)} + ) + return super().get_context_data(**kwargs) + user_profile = UserProfile.as_view() From a89e6622eda51af6065f48aa332f88da30da546e Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 21 Aug 2023 17:16:34 +0200 Subject: [PATCH 2/2] User profile page: only display providers if there are some Someone uses uMap with classic auth username/password, and they don't want those empty HTML elements --- umap/templates/auth/user_form.html | 48 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/umap/templates/auth/user_form.html b/umap/templates/auth/user_form.html index c5401399..06d04079 100644 --- a/umap/templates/auth/user_form.html +++ b/umap/templates/auth/user_form.html @@ -19,30 +19,32 @@ -
-

{% trans "Your current providers" %}

-
    - {% for name in providers %}
  • {{ name|title }}
  • {% endfor %} -
-
-
-

{% trans "Connect to another provider" %}

-

- {% blocktrans %}It's a good habit to connect your account to more than one provider, in case one provider becomes unavailable, temporarily or even permanently.{% endblocktrans %} -

-
-
+
+

{% trans "Connect to another provider" %}

+

+ {% blocktrans %}It's a good habit to connect your account to more than one provider, in case one provider becomes unavailable, temporarily or even permanently.{% endblocktrans %} +

+
+ +
+
+ {% endif %}
{% endblock maincontent %}