Merge pull request #1271 from umap-project/add-provider
Allow to add more than one OAuth provider
This commit is contained in:
commit
90a272aabc
2 changed files with 34 additions and 1 deletions
|
@ -19,5 +19,32 @@
|
||||||
<input type="submit" value="{% trans 'Save' %}" />
|
<input type="submit" value="{% trans 'Save' %}" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% if backends.backends|length %}
|
||||||
|
<div class="row">
|
||||||
|
<h3>{% trans "Your current providers" %}</h3>
|
||||||
|
<ul>
|
||||||
|
{% for name in providers %}<li>{{ name|title }}</li>{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<h3>{% trans "Connect to another provider" %}</h3>
|
||||||
|
<p>
|
||||||
|
{% 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 %}
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<ul class="login-grid block-grid">
|
||||||
|
{% for name in backends.backends %}
|
||||||
|
{% if name not in providers %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url "social:begin" name %}"
|
||||||
|
class="umap-login-popup login-{{ name }}"
|
||||||
|
title="{{ name|title }}"></a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
||||||
|
|
|
@ -168,11 +168,17 @@ about = About.as_view()
|
||||||
class UserProfile(UpdateView):
|
class UserProfile(UpdateView):
|
||||||
model = User
|
model = User
|
||||||
form_class = UserProfileForm
|
form_class = UserProfileForm
|
||||||
success_url = reverse_lazy('user_profile')
|
success_url = reverse_lazy("user_profile")
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.get_queryset().get(pk=self.request.user.pk)
|
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()
|
user_profile = UserProfile.as_view()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue