Correction connexion équipe standard
L'utilisateur est maintenant déconnecté de CAS au passage en utilisateur standard
This commit is contained in:
parent
6ec42edd60
commit
a3ad34521c
2 changed files with 23 additions and 2 deletions
|
@ -35,12 +35,24 @@
|
|||
<li><a href="{% url 'kfet.checkout' %}">Caisses</a></li>
|
||||
<li><a href="{% url 'kfet.article' %}">Articles</a></li>
|
||||
{% if request.user.username != 'kfet_genericteam' %}
|
||||
<li><a href="{% url 'kfet.login.genericteam' %}">Connexion standard</a></li>
|
||||
<li><a href="{% url 'kfet.login.genericteam' %}" target="_blank" id="genericteam">Connexion standard</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if request.user.is_authenticated %}
|
||||
<li><a href="/logout" title="Déconnexion"><span class="glyphicon glyphicon-log-out"></span></a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#genericteam').on('click', function () {
|
||||
setTimeout(function () { location.reload() }, 1000);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -22,6 +22,7 @@ from collections import defaultdict
|
|||
from channels import Group
|
||||
from kfet import consumers
|
||||
from datetime import timedelta
|
||||
import django_cas_ng
|
||||
|
||||
@login_required
|
||||
def home(request):
|
||||
|
@ -29,10 +30,18 @@ def home(request):
|
|||
|
||||
@permission_required('kfet.is_team')
|
||||
def login_genericteam(request):
|
||||
profile, _ = CofProfile.objects.get_or_create(user=request.user)
|
||||
logout_cas = ''
|
||||
if profile.login_clipper:
|
||||
logout_cas = django_cas_ng.views.logout(request)
|
||||
|
||||
token = GenericTeamToken.objects.create(token=get_random_string(50))
|
||||
user = authenticate(username="kfet_genericteam", token=token.token)
|
||||
login(request, user)
|
||||
print(request.user)
|
||||
|
||||
if logout_cas:
|
||||
return logout_cas
|
||||
|
||||
return render(request, "kfet/login_genericteam.html")
|
||||
|
||||
def put_cleaned_data_in_dict(dict, form):
|
||||
|
|
Loading…
Reference in a new issue