login thingy

This commit is contained in:
2024-02-20 17:52:52 +01:00
parent fdbdebca2a
commit 2eeb8eee10
5 changed files with 52 additions and 18 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

+10
View File
@@ -38,6 +38,11 @@ body {
min-width: 300px; min-width: 300px;
} }
.window.popup.login {
width: 380px;
left: calc(50% - 190px);
}
.window.popup .window-body { .window.popup .window-body {
display: flex; display: flex;
flex-flow: row nowrap; flex-flow: row nowrap;
@@ -58,6 +63,11 @@ body {
background-image: url('img/check.png'); background-image: url('img/check.png');
} }
.window.popup .window-body .icon.login {
background-image: url('img/login.png');
background-attachment:unset;
}
.window.popup .window-body .icon.error { .window.popup .window-body .icon.error {
background-image: url('img/error.png'); background-image: url('img/error.png');
} }
-3
View File
@@ -25,9 +25,6 @@
<li role="tab" {% if request.path == '/track/' %}aria-selected="true" {% endif %}> <li role="tab" {% if request.path == '/track/' %}aria-selected="true" {% endif %}>
<a href="{% url 'nominate' %}">Nomineren</a> <a href="{% url 'nominate' %}">Nomineren</a>
</li> </li>
<li role="tab" {% if request.path == '/' %}aria-selected="true" {% endif %}>
<a href="/">Statistieken</a>
</li>
</menu> </menu>
<div class="window" role="tabpanel"> <div class="window" role="tabpanel">
<div class="window-body"> <div class="window-body">
+36 -13
View File
@@ -1,13 +1,36 @@
{% extends "Base.html" %} {% load static %}
<html>
{% block main-content %} <head>
{% if user.is_authenticated %} {% include "head.html" %}
<p>Current user: {{ user.email }}</p> </head>
<form action="{% url 'oidc_logout' %}" method="post"> <body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
{% csrf_token %} <div class="window popup login" id="info-window">
<input type="submit" value="logout"> <div class="title-bar">
</form> <div class="title-bar-text">Welkom bij Muzak</div>
{% else %} <div class="title-bar-controls">
<a href="{% url 'oidc_authentication_init' %}">Login</a> <button aria-label="Close" onclick="hidePopup()"></button>
{% endif %} </div>
{% endblock %} </div>
<div class="window-body">
<div class="icon login"></div>
<div class="text">
<div>
{% if user.is_authenticated %}
<p>Current user: {{ user.email }}</p>
<form action="{% url 'oidc_logout' %}" method="post">
{% csrf_token %}
<input type="submit" value="logout">
</form>
{% else %}
<p>Gebruik onderstaande knop om in te loggen.</p>
<p>Als je geen inloggegevens hebt, meld je dan bij de beheerder van deze site.</p>
<form action="{% url 'oidc_authentication_init' %}" method="get">
<input type="submit" value="Login">
</form>
{% endif %}
</div>
</div>
</div>
</div>
</body>
</html>
+6 -2
View File
@@ -1,6 +1,6 @@
from django.shortcuts import render from django.shortcuts import render
from django.views import View from django.views import View
from django.http import HttpResponse from django.http import HttpResponse, HttpResponseRedirect
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
import re import re
@@ -13,7 +13,11 @@ spt = spotify.Spotify()
class AuthView(View): class AuthView(View):
def get(self, request): def get(self, request):
return TemplateResponse(request, "Login.html", {}) if request.user.is_authenticated:
#return TemplateResponse(request, "Nominate.html", {})
return HttpResponseRedirect('/vote')
else:
return TemplateResponse(request, "Login.html", {})
class VoteView(LoginRequiredMixin, View): class VoteView(LoginRequiredMixin, View):
def get(self, request, error=None): def get(self, request, error=None):