diff --git a/accounts/templates/accounts/login.html b/accounts/templates/accounts/login.html
index 8e81099..31eb78f 100644
--- a/accounts/templates/accounts/login.html
+++ b/accounts/templates/accounts/login.html
@@ -1,4 +1,21 @@
{% extends 'base.html' %}
{% block content %}
- HI
+ {% if error %}
+ {{ error }}
+
+
+ {% endif %}
+
Login
+
{% endblock %}
diff --git a/accounts/views.py b/accounts/views.py
index 03da391..fdccbe0 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -20,8 +20,18 @@ def signup(request):
def login(request):
- return render(request, 'accounts/login.html')
+ if request.method == 'POST':
+ user = auth.authenticate(username=request.POST['username'], password=request.POST['password'])
+ if user is not None:
+ auth.login(request, user)
+ return redirect('home')
+ else:
+ return render(request, 'accounts/login.html', {'error': 'username or password incorrect'})
+ else:
+ return render(request, 'accounts/login.html')
def logout(request):
- return render(request, '/accounts/login.html')
+ if request.method == 'POST':
+ auth.logout(request)
+ return redirect('home')
diff --git a/producthunt/templates/base.html b/producthunt/templates/base.html
index 7531969..3501321 100644
--- a/producthunt/templates/base.html
+++ b/producthunt/templates/base.html
@@ -50,8 +50,16 @@
diff --git a/products/templates/products/home.html b/products/templates/products/home.html
index 8e81099..c2402fa 100644
--- a/products/templates/products/home.html
+++ b/products/templates/products/home.html
@@ -1,4 +1,8 @@
{% extends 'base.html' %}
{% block content %}
- HI
+ {% if error %}
+ {{ error }}
+
+
+ {% endif %}
{% endblock %}