Show More
@@ -25,9 +25,10 b'' | |||
|
25 | 25 | |
|
26 | 26 | import logging |
|
27 | 27 | import formencode |
|
28 | import datetime | |
|
28 | 29 | |
|
29 | 30 | from formencode import htmlfill |
|
30 | ||
|
31 | from webob.exc import HTTPFound | |
|
31 | 32 | from pylons.i18n.translation import _ |
|
32 | 33 | from pylons.controllers.util import abort, redirect |
|
33 | 34 | from pylons import request, response, session, tmpl_context as c, url |
@@ -41,6 +42,7 b' from rhodecode.model.user import UserMod' | |||
|
41 | 42 | from rhodecode.model.meta import Session |
|
42 | 43 | |
|
43 | 44 | |
|
45 | ||
|
44 | 46 | log = logging.getLogger(__name__) |
|
45 | 47 | |
|
46 | 48 | |
@@ -62,6 +64,7 b' class LoginController(BaseController):' | |||
|
62 | 64 | # import Login Form validator class |
|
63 | 65 | login_form = LoginForm() |
|
64 | 66 | try: |
|
67 | session.invalidate() | |
|
65 | 68 | c.form_result = login_form.to_python(dict(request.POST)) |
|
66 | 69 | # form checks for username/password, now we're authenticated |
|
67 | 70 | username = c.form_result['username'] |
@@ -70,22 +73,33 b' class LoginController(BaseController):' | |||
|
70 | 73 | auth_user.set_authenticated() |
|
71 | 74 | cs = auth_user.get_cookie_store() |
|
72 | 75 | session['rhodecode_user'] = cs |
|
76 | user.update_lastlogin() | |
|
77 | Session().commit() | |
|
78 | ||
|
73 | 79 | # If they want to be remembered, update the cookie |
|
74 | 80 | if c.form_result['remember'] is not False: |
|
75 | session.cookie_expires = False | |
|
76 | session._set_cookie_values() | |
|
77 |
session._ |
|
|
81 | _year = (datetime.datetime.now() + | |
|
82 | datetime.timedelta(seconds=60 * 60 * 24 * 365)) | |
|
83 | session._set_cookie_expires(_year) | |
|
84 | ||
|
78 | 85 | session.save() |
|
79 | 86 | |
|
80 | 87 | log.info('user %s is now authenticated and stored in ' |
|
81 | 88 | 'session, session attrs %s' % (username, cs)) |
|
82 | user.update_lastlogin() | |
|
83 | Session.commit() | |
|
89 | ||
|
90 | # dumps session attrs back to cookie | |
|
91 | session._update_cookie_out() | |
|
92 | ||
|
93 | # we set new cookie | |
|
94 | headers = None | |
|
95 | if session.request['set_cookie']: | |
|
96 | # send set-cookie headers back to response to update cookie | |
|
97 | headers = [('Set-Cookie', session.request['cookie_out'])] | |
|
84 | 98 | |
|
85 | 99 | if c.came_from: |
|
86 | return redirect(c.came_from) | |
|
100 | raise HTTPFound(location=c.came_from, headers=headers) | |
|
87 | 101 | else: |
|
88 | return redirect(url('home')) | |
|
102 | raise HTTPFound(location=url('home'), headers=headers) | |
|
89 | 103 | |
|
90 | 104 | except formencode.Invalid, errors: |
|
91 | 105 | return htmlfill.render( |
@@ -115,7 +129,7 b' class LoginController(BaseController):' | |||
|
115 | 129 | UserModel().create_registration(form_result) |
|
116 | 130 | h.flash(_('You have successfully registered into rhodecode'), |
|
117 | 131 | category='success') |
|
118 | Session.commit() | |
|
132 | Session().commit() | |
|
119 | 133 | return redirect(url('login_home')) |
|
120 | 134 | |
|
121 | 135 | except formencode.Invalid, errors: |
General Comments 0
You need to be logged in to leave comments.
Login now