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

Server error fix #323

Merged
merged 9 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added auth_user
4-dash committed Dec 20, 2024

Verified

This commit was signed with the committer’s verified signature.
commit d4b6149c0273ca9b218c8cb9da335aabfc412e4d
1 change: 1 addition & 0 deletions src/feedback/urls.py
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@
urlpatterns += [
re_path(r'^intern/rechte_uebernehmen/$', feedback.views.intern.auth.rechte_uebernehmen, name='rechte-uebernehmen'),
re_path(r'^intern/rechte_zuruecknehmen/$', feedback.views.intern.auth.rechte_zuruecknehmen, name='rechte_zuruecknehmen'),
re_path(r'^intern/auth_user/$', feedback.views.intern.auth.auth_user, name='auth-user'),
re_path(r'^intern/$', feedback.views.intern.auth.login, name='auth-login'),
]

17 changes: 17 additions & 0 deletions src/feedback/views/intern/auth.py
Original file line number Diff line number Diff line change
@@ -54,6 +54,20 @@ def rechte_zuruecknehmen(request):
return HttpResponseRedirect(reverse('feedback:intern-index'))


def auth_user(request) :
if request.method == "POST" :
username = request.POST.get("username")
password = request.POST.get("password")

user = auth.authenticate(username=username, password=password)

if user is None :
messages.error(request, "Invalid Password")
else :
auth.login(request, user)

return HttpResponseRedirect(reverse('feedback:auth-login'))

@require_safe
def login(request):
if settings.DEBUG and not request.user.is_superuser:
@@ -63,6 +77,9 @@ def login(request):
response['WWW-Authenticate'] = 'Basic realm="Feedback"'
return response

if not request.user.is_superuser :
return render(request, 'registration/login.html')

# Apache fordert User zum Login mit FS-Account auf, von daher muss hier nur noch weitergeleitet
# werden.
return HttpResponseRedirect(reverse('feedback:intern-index'))
15 changes: 15 additions & 0 deletions src/templates/registration/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "d120_base.html" %}

{% block section_veranstalter %}current{% endblock section_veranstalter %}
{% block title %}Login{% endblock title %}
{% block content %}
<form method="post" action="{% url "feedback:auth-user" %}">
{% csrf_token %}
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"><br><br>

<input type="submit" value="Submit">
</form>
{% endblock content %}