Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
135 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
from django.contrib.auth import views, logout | ||
from django.http import HttpResponseRedirect | ||
from django.urls import path, reverse | ||
from django.utils.decorators import method_decorator | ||
from django.views.decorators.cache import never_cache | ||
from django.views.generic import TemplateView | ||
|
||
|
||
class Home(TemplateView): | ||
template_name = 'home.html' | ||
|
||
|
||
class Login(views.LoginView): | ||
template_name='login.html' | ||
|
||
def get_success_url(self): | ||
return reverse('homepage') | ||
|
||
|
||
class Logout(views.LogoutView): | ||
template_name='logout.html' | ||
|
||
def post(self, request, *args, **kwargs): | ||
logout(request) | ||
return HttpResponseRedirect(reverse('homepage')) | ||
|
||
@method_decorator(never_cache) | ||
def dispatch(self, request, *args, **kwargs): | ||
# Standard View class dispatcher. | ||
# (Don't logout on GET, only POST) | ||
if request.method.lower() in self.http_method_names: | ||
handler = getattr( | ||
self, | ||
request.method.lower(), | ||
self.http_method_not_allowed | ||
) | ||
else: | ||
handler = self.http_method_not_allowed | ||
return handler(request, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
<head> | ||
|
||
</head> | ||
<body> | ||
{% block content %} | ||
{% endblock %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
<html> | ||
<body> | ||
<h1>hasworn.com temporary holding page</h1> | ||
<p>Testing deploys</p> | ||
</body> | ||
</html> | ||
{% extends "base_template.html" %} | ||
|
||
{% block content %} | ||
{% if user.is_authenticated %} | ||
<form method='post' action='{% url "logout" %}'> | ||
{% csrf_token %} | ||
<input type='submit' value='Logout'> | ||
</form> | ||
{% else %} | ||
|
||
<form method='post' action='{% url "login" %}'> | ||
{% csrf_token %} | ||
<label> | ||
Username: | ||
<input type='text' name='username' autofocus='' autocapitalize='none' autocomplete='username' maxlength='30' required='' id='id_username'> | ||
</label> | ||
<label> | ||
Password: | ||
<input type='password' name='password' autocomplete='current-password' required='' id='id_password'> | ||
</label> | ||
<input type='submit' value='login'> | ||
</form> | ||
|
||
{% comment %} | ||
{# Assumes you setup the password_reset view in your URLconf #} | ||
<p><a href="{% url 'password_reset' %}">Lost password?</a></p> | ||
{% endcomment %} | ||
|
||
{% endif %} | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{% extends "base_template.html" %} | ||
|
||
{% block content %} | ||
|
||
{% if form.errors %} | ||
<p>Your username and password didn't match. Please try again.</p> | ||
{% endif %} | ||
|
||
{% if next %} | ||
{% if user.is_authenticated %} | ||
<p>Your account doesn't have access to this page. To proceed, | ||
please login with an account that has access.</p> | ||
{% else %} | ||
<p>Please login to see this page.</p> | ||
{% endif %} | ||
{% endif %} | ||
|
||
<form method="post" action="{% url 'login' %}"> | ||
{% csrf_token %} | ||
<table> | ||
<tr> | ||
<td>{{ form.username.label_tag }}</td> | ||
<td>{{ form.username }}</td> | ||
</tr> | ||
<tr> | ||
<td>{{ form.password.label_tag }}</td> | ||
<td>{{ form.password }}</td> | ||
</tr> | ||
</table> | ||
|
||
<input type="submit" value="login"> | ||
<input type="hidden" name="next" value="{{ next }}"> | ||
</form> | ||
|
||
{% comment %} | ||
{# Assumes you setup the password_reset view in your URLconf #} | ||
<p><a href="{% url 'password_reset' %}">Lost password?</a></p> | ||
{% endcomment %} | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "base_template.html" %} | ||
|
||
{% block content %} | ||
{% if user.is_authenticated %} | ||
<form method='post' action='{% url "logout" %}'> | ||
{% csrf_token %} | ||
<button type='submit'>Logout</button> | ||
</form> | ||
{% else %} | ||
<p>Already logged out.</p> | ||
{% endif %} | ||
{% endblock %} |