feat(account): Add a template with a message when a CAS account is forbidden
This commit is contained in:
parent
5af8e2fd24
commit
cd8859f610
3 changed files with 17 additions and 1 deletions
|
@ -7,4 +7,9 @@ app_name = "dgsi"
|
|||
urlpatterns = [
|
||||
path("accounts/profile/", views.ProfileView.as_view(), name="dgn-profile"),
|
||||
path("accounts/create/", views.CreateUserView.as_view(), name="dgn-create_user"),
|
||||
path(
|
||||
"accounts/forbidden/",
|
||||
views.TemplateView.as_view(template_name="account/forbidden_category.html"),
|
||||
name="dgn-forbidden_account",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -2,6 +2,7 @@ from allauth.core.exceptions import ImmediateHttpResponse
|
|||
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
||||
from allauth.socialaccount.models import SocialLogin
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
||||
from dgsi.models import User
|
||||
|
||||
|
@ -25,7 +26,9 @@ class SharedAccountAdapter(DefaultSocialAccountAdapter):
|
|||
home[2]
|
||||
in ["absint", "algo", "grecc", "guests", "spi", "spi1", "staffs"]
|
||||
):
|
||||
raise ImmediateHttpResponse(HttpResponseRedirect("/"))
|
||||
raise ImmediateHttpResponse(
|
||||
HttpResponseRedirect(reverse("dgsi:dgn-forbidden_account"))
|
||||
)
|
||||
|
||||
case "kanidm":
|
||||
username = sociallogin.account.extra_data["preferred_username"]
|
||||
|
|
8
src/shared/templates/account/forbidden_category.html
Normal file
8
src/shared/templates/account/forbidden_category.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="notification is-warning is-light px-5 py-5 has-text-centered is-size-5">
|
||||
{% blocktrans %}Votre catégorie de compte ENS ne permet pas de vous identifier auprès de la DGNum.<br>Si vous pensez qu'il s'agit une erreur, merci de contacter la DGNum à l'adresse : <a href="mailto:contact@dgnum.eu">contact@dgnum.eu</a>{% endblocktrans %}
|
||||
</div>
|
||||
{% endblock content %}
|
Loading…
Reference in a new issue