7 ] |
7 ] |
8 |
8 |
9 |
9 |
10 from django.contrib.auth import authenticate |
10 from django.contrib.auth import authenticate |
11 from django.contrib.auth import login |
11 from django.contrib.auth import login |
|
12 from django.contrib.auth import logout |
12 from django.contrib.auth.forms import AuthenticationForm |
13 from django.contrib.auth.forms import AuthenticationForm |
13 from django.contrib.auth.models import User |
14 from django.contrib.auth.models import User |
|
15 from django.core.urlresolvers import reverse |
14 from django.db import IntegrityError |
16 from django.db import IntegrityError |
15 from django.http import HttpResponseRedirect |
17 from django.http import HttpResponseRedirect |
16 from django.shortcuts import render_to_response |
18 from django.shortcuts import render_to_response |
17 from django.shortcuts import get_object_or_404 |
19 from django.shortcuts import get_object_or_404 |
18 |
20 |
19 |
21 |
20 def login_validate(request): |
22 def login_validate(request): |
21 """Validate the user and log him in. |
23 """Validate the user and log him in. |
22 """ |
24 """ |
|
25 |
|
26 template = 'projrev/auth/login.html' |
|
27 context = {} |
23 |
28 |
24 if request.POST: |
29 if request.POST: |
25 username = request.POST['username'] |
30 username = request.POST['username'] |
26 password = request.POST['password'] |
31 password = request.POST['password'] |
27 user = authenticate(username=username, password=password) |
32 user = authenticate(username=username, password=password) |
32 else: |
37 else: |
33 pass |
38 pass |
34 # Return a 'disabled account' error message |
39 # Return a 'disabled account' error message |
35 else: |
40 else: |
36 # Return an 'invalid login' error message. |
41 # Return an 'invalid login' error message. |
37 pass |
42 context['error'] = True |
38 else: |
|
39 context = {} |
|
40 template = 'projrev/auth/login.html' |
|
41 |
43 |
42 return render_to_response(template, context) |
44 return render_to_response(template, context) |
43 |
45 |
44 def create_account(request): |
46 def create_account(request): |
45 """Create an account for a user. |
47 """Create an account for a user. |