##// END OF EJS Templates
login: removed log_session model, and replaced it with two lines of code....
marcink -
r1321:cb7ffeab default
parent child Browse files
Show More
@@ -39,7 +39,6 b' from rhodecode.lib.exceptions import Use'
39 from rhodecode.lib.utils2 import safe_str
39 from rhodecode.lib.utils2 import safe_str
40 from rhodecode.model.db import User
40 from rhodecode.model.db import User
41 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
41 from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm
42 from rhodecode.model.login_session import LoginSession
43 from rhodecode.model.meta import Session
42 from rhodecode.model.meta import Session
44 from rhodecode.model.settings import SettingsModel
43 from rhodecode.model.settings import SettingsModel
45 from rhodecode.model.user import UserModel
44 from rhodecode.model.user import UserModel
@@ -158,11 +157,11 b' class LoginView(object):'
158 renderer='rhodecode:templates/login.mako')
157 renderer='rhodecode:templates/login.mako')
159 def login_post(self):
158 def login_post(self):
160 came_from = get_came_from(self.request)
159 came_from = get_came_from(self.request)
161 session = self.request.session
160
162 login_form = LoginForm()()
161 login_form = LoginForm()()
163
162
164 try:
163 try:
165 session.invalidate()
164 self.session.invalidate()
166 form_result = login_form.to_python(self.request.params)
165 form_result = login_form.to_python(self.request.params)
167 # form checks for username/password, now we're authenticated
166 # form checks for username/password, now we're authenticated
168 headers = _store_user_in_session(
167 headers = _store_user_in_session(
@@ -187,13 +186,15 b' class LoginView(object):'
187 # the fly can throw this exception signaling that there's issue
186 # the fly can throw this exception signaling that there's issue
188 # with user creation, explanation should be provided in
187 # with user creation, explanation should be provided in
189 # Exception itself
188 # Exception itself
190 session.flash(e, queue='error')
189 self.session.flash(e, queue='error')
191 return self._get_template_context()
190 return self._get_template_context()
192
191
193 @CSRFRequired()
192 @CSRFRequired()
194 @view_config(route_name='logout', request_method='POST')
193 @view_config(route_name='logout', request_method='POST')
195 def logout(self):
194 def logout(self):
196 LoginSession().destroy_user_session()
195 user = self.request.user
196 log.info('Deleting session for user: `%s`', user)
197 self.session.delete()
197 return HTTPFound(url('home'))
198 return HTTPFound(url('home'))
198
199
199 @HasPermissionAnyDecorator(
200 @HasPermissionAnyDecorator(
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now