Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI page for social login #483

Merged
merged 24 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/pretix/control/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ def get_admin_navigation(request):
'url': reverse('control:admin.global.sso'),
'active': (url.url_name == 'admin.global.sso'),
},
{
'label': _('Social login settings'),
'url': reverse('plugins:socialauth:admin.global.social.auth.settings'),
'active': (url.url_name == 'admin.global.social.auth.settings')
}
]
},
]
Expand Down
4 changes: 4 additions & 0 deletions src/pretix/control/templates/pretixcontrol/auth/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<link rel="stylesheet" type="text/x-scss" href="{% static "pretixcontrol/scss/auth.scss" %}"/>
<link rel="stylesheet" type="text/x-scss" href="{% static "pretixcontrol/scss/main.scss" %}" />
{% endcompress %}
{% compress js %}
<script type="text/javascript" src="{% static "jquery/js/jquery-3.7.1.min.js" %}"></script>
<script type="text/javascript" src="{% static "bootstrap/js/bootstrap.js" %}"></script>
{% endcompress %}
<meta name="viewport" content="width=device-width, initial-scale=1">

{% if development_warning or debug_warning %}
Expand Down
88 changes: 53 additions & 35 deletions src/pretix/control/templates/pretixcontrol/auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,63 @@
{% load append_next_url %}
{% block content %}
<form class="form-signin" action="" method="post">
{% if backends|length > 1 %}
<ul class="nav nav-pills">
{% for b in backends %}
{% if b.visible %}
<li class="{% if backend.identifier == b.identifier %}active{% endif %}">
<a href="{% if b.url %}{{ b.url }}{% else %}?{% url_replace request "backend" b.identifier %}{% endif %}">
{{ b.verbose_name }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
<br>
{% endif %}
{% csrf_token %}
{% bootstrap_form form %}
<div class="form-group buttons">
{% if backend.login_form_fields %}
<button type="submit" class="btn btn-primary btn-block">
{% trans "Log in" %}
</button>
<div id="login-form" class="collapse">
{% if backends|length > 1 %}
<ul class="nav nav-pills">
{% for b in backends %}
{% if b.visible %}
<li class="{% if backend.identifier == b.identifier %}active{% endif %}">
<a href="{% if b.url %}{{ b.url }}{% else %}?{% url_replace request "backend" b.identifier %}{% endif %}">
{{ b.verbose_name }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
<br>
{% endif %}
{% if backend.url %}
<a href="{{ backend.url }}" class="btn btn-primary btn-block">
{{ backend.verbose_name }}
</a>
{% endif %}
{% if backend.identifier == "native" %}
{% if can_reset %}
<a href="{% url "control:auth.forgot" %}" class="btn btn-link btn-block">
{% trans "Lost password?" %}
</a>
{% csrf_token %}
{% bootstrap_form form %}
<div class="form-group buttons">
{% if backend.login_form_fields %}
<button type="submit" class="btn btn-primary btn-block">
{% trans "Log in" %}
</button>
{% endif %}
{% if can_register %}
<a href='{% url "control:auth.register" %}{% append_next request.GET.next %}' class="btn btn-link btn-block">
{% trans "Register" %}
{% if backend.url %}
<a href="{{ backend.url }}" class="btn btn-primary btn-block">
{{ backend.verbose_name }}
</a>
{% endif %}
{% endif %}
{% if backend.identifier == "native" %}
{% if can_reset %}
<a href="{% url "control:auth.forgot" %}" class="btn btn-link btn-block">
{% trans "Lost password?" %}
</a>
{% endif %}
{% if can_register %}
<a href='{% url "control:auth.register" %}{% append_next request.GET.next %}' class="btn btn-link btn-block">
{% trans "Register" %}
</a>
{% endif %}
{% endif %}
</div>
</div>
<div class="form-group buttons">
<button type="button" class="btn btn-primary btn-block" data-toggle="collapse" data-target="#login-form">
{% trans "Login with Email" %}
</button>
{% if login_providers %}
{% for provider, enable in login_providers.items %}
{% if enable %}
<a href='{% url "plugins:socialauth:social.oauth.login" provider %}' data-method="post" class="btn btn-primary btn-block">
{% with provider|capfirst as provider_capitalized %}
{% blocktrans %}Login with {{ provider_capitalized }}{% endblocktrans %}
{% endwith %}
</a>
{% endif %}
{% endfor %}
{% endif %}
</div
</form>
{% endblock %}
1 change: 0 additions & 1 deletion src/pretix/control/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@
url(r'^vouchers/(?P<voucher>\d+)/$', admin.VoucherUpdate.as_view(), name='admin.voucher'),
url(r'^vouchers/(?P<voucher>\d+)/delete$', admin.VoucherDelete.as_view(),
name='admin.voucher.delete'),

url(r'^global/sso/$', global_settings.SSOView.as_view(), name='admin.global.sso'),
url(r'^global/sso/(?P<pk>\d+)/delete/$', global_settings.DeleteOAuthApplicationView.as_view(), name='admin.global.sso.delete'),
url(r'^pages/$', pages.PageList.as_view(), name="admin.pages"),
Expand Down
4 changes: 4 additions & 0 deletions src/pretix/control/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from pretix.base.models import TeamInvite, U2FDevice, User, WebAuthnDevice
from pretix.base.models.page import Page
from pretix.base.services.mail import SendMailException
from pretix.base.settings import GlobalSettingsObject
from pretix.helpers.cookies import set_cookie_without_samesite
from pretix.helpers.jwt_generate import generate_sso_token
from pretix.multidomain.middlewares import get_cookie_domain
Expand Down Expand Up @@ -130,6 +131,9 @@ def login(request):
ctx['can_reset'] = settings.PRETIX_PASSWORD_RESET
ctx['backends'] = backends
ctx['backend'] = backend

gs = GlobalSettingsObject()
ctx['login_providers'] = gs.settings.get('login_providers', as_type=dict)
return render(request, 'pretixcontrol/auth/login.html', ctx)


Expand Down
6 changes: 6 additions & 0 deletions src/pretix/locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -24410,3 +24410,9 @@ msgstr "هل تريد إنشاء حساب %(event_name)s؟"

msgid "Already have a %(event_name)s account?"
msgstr "هل لديك حساب %(event_name)s بالفعل؟"

msgid "Login with %(provider_capitalized)s"
msgstr "تسجيل الدخول باستخدام %(provider_capitalized)s"

msgid "Login with email"
msgstr "تسجيل الدخول باستخدام البريد الإلكتروني"
6 changes: 6 additions & 0 deletions src/pretix/locale/ca/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -23300,3 +23300,9 @@ msgstr "Voleu crear un compte de %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Ja teniu un compte de %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Inicieu sessió amb %(provider_capitalized)s"

msgid "Login with email"
msgstr "Inicieu sessió amb correu electrònic"
6 changes: 6 additions & 0 deletions src/pretix/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21182,3 +21182,9 @@ msgstr "Voleu crear un compte de %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Ja teniu un compte de %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Přihlásit se přes %(provider_capitalized)s"

msgid "Login with email"
msgstr "Přihlásit se přes e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/da/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -24711,3 +24711,9 @@ msgstr "Vil du oprette en %(event_name)s konto?"

msgid "Already have a %(event_name)s account?"
msgstr "Har du allerede en %(event_name)s konto?"

msgid "Login with %(provider_capitalized)s"
msgstr "Log ind med %(provider_capitalized)s"

msgid "Login with email"
msgstr "Log ind med e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -25664,3 +25664,9 @@ msgstr "Möchten Sie ein %(event_name)s Konto erstellen?"

msgid "Already have a %(event_name)s account?"
msgstr "Haben Sie bereits ein %(event_name)s Konto?"

msgid "Login with %(provider_capitalized)s"
msgstr "Mit %(provider_capitalized)s anmelden"

msgid "Login with email"
msgstr "Mit E-Mail anmelden"
6 changes: 6 additions & 0 deletions src/pretix/locale/de_Informal/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -25610,3 +25610,9 @@ msgstr "Möchtest du ein %(event_name)s Konto erstellen?"

msgid "Already have a %(event_name)s account?"
msgstr "Hast du bereits ein %(event_name)s Konto?"

msgid "Login with %(provider_capitalized)s"
msgstr "Mit %(provider_capitalized)s einloggen"

msgid "Login with email"
msgstr "Mit E-Mail anmelden"
6 changes: 6 additions & 0 deletions src/pretix/locale/el/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -25767,3 +25767,9 @@ msgstr "Θέλετε να δημιουργήσετε έναν λογαριασμ

msgid "Already have a %(event_name)s account?"
msgstr "Έχετε ήδη λογαριασμό %(event_name)s;"

msgid "Login with %(provider_capitalized)s"
msgstr "Συνδεθείτε με το %(provider_capitalized)s"

msgid "Login with email"
msgstr "Συνδεθείτε με το email"
6 changes: 6 additions & 0 deletions src/pretix/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -25978,3 +25978,9 @@ msgstr "¿Quieres crear una cuenta de %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "¿Ya tienes una cuenta de %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Iniciar sesión con %(provider_capitalized)s"

msgid "Login with email"
msgstr "Iniciar sesión con correo electrónico"
6 changes: 6 additions & 0 deletions src/pretix/locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21342,3 +21342,9 @@ msgstr "Haluatko luoda %(event_name)s-tilin?"

msgid "Already have a %(event_name)s account?"
msgstr "Onko sinulla jo %(event_name)s-tili?"

msgid "Login with %(provider_capitalized)s"
msgstr "Kirjaudu sisään %(provider_capitalized)s"

msgid "Login with email"
msgstr "Kirjaudu sisään sähköpostilla"
6 changes: 6 additions & 0 deletions src/pretix/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -26665,3 +26665,9 @@ msgstr "Voulez-vous créer un compte %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Avez-vous déjà un compte %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Se connecter avec %(provider_capitalized)s"

msgid "Login with email"
msgstr "Se connecter avec email"
6 changes: 6 additions & 0 deletions src/pretix/locale/hu/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21261,3 +21261,9 @@ msgstr "Szeretnél létrehozni egy %(event_name)s fiókot?"

msgid "Already have a %(event_name)s account?"
msgstr "Már van %(event_name)s fiókod?"

msgid "Login with %(provider_capitalized)s"
msgstr "Bejelentkezés a %(provider_capitalized)s"

msgid "Login with email"
msgstr "Bejelentkezés e-maillel"
6 changes: 6 additions & 0 deletions src/pretix/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -22089,3 +22089,9 @@ msgstr "Vuoi creare un account %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Hai già un account %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Accedi con %(provider_capitalized)s"

msgid "Login with email"
msgstr "Accedi con email"
6 changes: 6 additions & 0 deletions src/pretix/locale/lv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -22593,3 +22593,9 @@ msgstr "Vai vēlaties izveidot %(event_name)s kontu?"

msgid "Already have a %(event_name)s account?"
msgstr "Vai jums jau ir %(event_name)s konts?"

msgid "Login with %(provider_capitalized)s"
msgstr "Pieteikties ar %(provider_capitalized)s"

msgid "Login with email"
msgstr "Pieteikties ar e-pastu"
6 changes: 6 additions & 0 deletions src/pretix/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -24828,3 +24828,9 @@ msgstr "Wil je een %(event_name)s account aanmaken?"

msgid "Already have a %(event_name)s account?"
msgstr "Heb je al een %(event_name)s account?"

msgid "Login with %(provider_capitalized)s"
msgstr "Inloggen met %(provider_capitalized)s"

msgid "Login with email"
msgstr "Inloggen met e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/nl_Informal/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -24699,3 +24699,9 @@ msgstr "Wil je een %(event_name)s account aanmaken?"

msgid "Already have a %(event_name)s account?"
msgstr "Heb je al een %(event_name)s account?"

msgid "Login with %(provider_capitalized)s"
msgstr "Inloggen met %(provider_capitalized)s"

msgid "Login with email"
msgstr "Inloggen met e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/pl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -22092,3 +22092,9 @@ msgstr "Chcesz utworzyć konto %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Masz już konto %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Zaloguj się z %(provider_capitalized)s"

msgid "Login with email"
msgstr "Zaloguj się za pomocą e-maila"
6 changes: 6 additions & 0 deletions src/pretix/locale/pl_Informal/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21064,3 +21064,9 @@ msgstr "Chcesz utworzyć konto %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Masz już konto %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Zaloguj się z %(provider_capitalized)s"

msgid "Login with email"
msgstr "Zaloguj się za pomocą e-maila"
6 changes: 6 additions & 0 deletions src/pretix/locale/pt/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21063,3 +21063,9 @@ msgstr "Quer criar uma conta %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Já tem uma conta %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Iniciar sessão com %(provider_capitalized)s"

msgid "Login with email"
msgstr "Iniciar sessão com e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/pt_BR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -22886,3 +22886,9 @@ msgstr "Quer criar uma conta %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Já tem uma conta %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Entrar com o %(provider_capitalized)s"

msgid "Login with email"
msgstr "Entrar com e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/pt_PT/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -24103,3 +24103,9 @@ msgstr "Quer criar uma conta %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Já tem uma conta %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Entrar com o %(provider_capitalized)s"

msgid "Login with email"
msgstr "Entrar com e-mail"
6 changes: 6 additions & 0 deletions src/pretix/locale/ro/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21066,3 +21066,9 @@ msgstr "Doriți să creați un cont %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Aveți deja un cont %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Conectează-te cu %(provider_capitalized)s"

msgid "Login with email"
msgstr "Conectează-te cu email"
6 changes: 6 additions & 0 deletions src/pretix/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -22680,3 +22680,9 @@ msgstr "Хотите создать аккаунт %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "У вас уже есть аккаунт %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Войти с %(provider_capitalized)s"

msgid "Login with email"
msgstr "Войти с email"
6 changes: 6 additions & 0 deletions src/pretix/locale/sl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -21940,3 +21940,9 @@ msgstr "ඔබට %(event_name)s ගිණුමක් සාදන්න අව

msgid "Already have a %(event_name)s account?"
msgstr "ඔබට දැනටමත් %(event_name)s ගිණුමක් තිබේද?"

msgid "Login with %(provider_capitalized)s"
msgstr "Prijavite se z %(provider_capitalized)s"

msgid "Login with email"
msgstr "Prijavite se z e-pošto"
8 changes: 7 additions & 1 deletion src/pretix/locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -22081,4 +22081,10 @@ msgid "Want to create a %(event_name)s account?"
msgstr "Želite ustvariti račun %(event_name)s?"

msgid "Already have a %(event_name)s account?"
msgstr "Ali že imate račun %(event_name)s?"
msgstr "Ali že imate račun %(event_name)s?"

msgid "Login with %(provider_capitalized)s"
msgstr "Logga in med %(provider_capitalized)s"

msgid "Login with email"
msgstr "Logga in med e-post"
Loading
Loading