added option for linking SSO accounts to existing accounts
This commit is contained in:
parent
de006a5761
commit
b70f89a341
2 changed files with 27 additions and 2 deletions
|
@ -48,6 +48,17 @@
|
|||
<a class="button" href="{% url 'site.api_secret_list' %}">{% trans 'Manage API secrets' %}</a>
|
||||
</p>
|
||||
|
||||
{% if sso_backends %}
|
||||
<hr>
|
||||
<p>{% trans %}SSO Connections:{% endtrans %}</p>
|
||||
{% for backend, name in sso_backends.not_associated.items %}
|
||||
<p><a class="button" href="{% url 'social:begin' backend=backend %}?next={% url 'site.account' %}">Link {{ name }}</a></p>
|
||||
{% endfor %}
|
||||
{% for backend, name in sso_backends.associated.items %}
|
||||
<p><a class="button delete" href="{% url 'social:disconnect' backend=backend %}?next={% url 'site.account' %}">Unlink {{ name }}</a></p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
<a class="button" href="{% url 'site.logout' %}">{% trans 'Log out' %}</a>
|
||||
|
|
|
@ -416,9 +416,23 @@ def delete_account_view(request):
|
|||
@never_cache
|
||||
@login_required(login_url='site.login')
|
||||
def account_view(request):
|
||||
return render(request, 'site/account.html', {
|
||||
ctx = {
|
||||
'user_has_reports': Report.user_has_reports(request.user),
|
||||
})
|
||||
}
|
||||
if settings.SSO_ENABLED:
|
||||
from social_core.backends.utils import user_backends_data
|
||||
from social_django.utils import Storage
|
||||
from c3nav.control.sso import get_sso_services
|
||||
sso_services = get_sso_services()
|
||||
ctx['sso_services'] = sso_services
|
||||
backends = user_backends_data(
|
||||
request.user, settings.AUTHENTICATION_BACKENDS, Storage
|
||||
)
|
||||
ctx['sso_backends'] = {
|
||||
'associated': {backend.provider: sso_services[backend.provider] for backend in backends["associated"] },
|
||||
'not_associated': {backend: sso_services[backend] for backend in backends["not_associated"] },
|
||||
}
|
||||
return render(request, 'site/account.html', ctx)
|
||||
|
||||
|
||||
@never_cache
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue