##// END OF EJS Templates
updated logging in logout. Added before, on login page.
marcink -
r202:3fd2af1b default
parent child Browse files
Show More
@@ -1,38 +1,42 b''
1 1 import logging
2 2 from formencode import htmlfill
3 3 from pylons import request, response, session, tmpl_context as c, url
4 4 from pylons.controllers.util import abort, redirect
5 5 from pylons_app.lib.base import BaseController, render
6 6 import formencode
7 7 from pylons_app.model.forms import LoginForm
8 8 from pylons_app.lib.auth import AuthUser
9 9
10 10 log = logging.getLogger(__name__)
11 11
12 12 class LoginController(BaseController):
13 13
14 def __before__(self):
15 super(LoginController, self).__before__()
16
14 17 def index(self):
15 18 #redirect if already logged in
16 19 if c.hg_app_user.is_authenticated:
17 20 return redirect(url('hg_home'))
18 21
19 22 if request.POST:
20 23 #import Login Form validator class
21 24 login_form = LoginForm()
22 25 try:
23 26 c.form_result = login_form.to_python(dict(request.POST))
24 27 return redirect(url('hg_home'))
25 28
26 29 except formencode.Invalid as errors:
27 30 c.form_errors = errors.error_dict
28 31 return htmlfill.render(
29 32 render('/login.html'),
30 33 defaults=errors.value,
31 34 encoding="UTF-8")
32 35
33 36 return render('/login.html')
34 37
35 38 def logout(self):
36 39 session['hg_app_user'] = AuthUser()
37 40 session.save()
41 log.info('Logging out and setting user as Empty')
38 42 redirect(url('hg_home'))
General Comments 0
You need to be logged in to leave comments. Login now