# HG changeset patch # User Marcin Kuzminski # Date 2017-01-13 13:04:44 # Node ID cb7ffeab61d9118ec77ee58bd82623393f947ee5 # Parent ffa9596da4b928f5d74f94a404373a56a6af3bd3 login: removed log_session model, and replaced it with two lines of code. - also remove usage of template context - having dedicated model for this operation wasn't really required. diff --git a/rhodecode/login/views.py b/rhodecode/login/views.py --- a/rhodecode/login/views.py +++ b/rhodecode/login/views.py @@ -39,7 +39,6 @@ from rhodecode.lib.exceptions import Use from rhodecode.lib.utils2 import safe_str from rhodecode.model.db import User from rhodecode.model.forms import LoginForm, RegisterForm, PasswordResetForm -from rhodecode.model.login_session import LoginSession from rhodecode.model.meta import Session from rhodecode.model.settings import SettingsModel from rhodecode.model.user import UserModel @@ -158,11 +157,11 @@ class LoginView(object): renderer='rhodecode:templates/login.mako') def login_post(self): came_from = get_came_from(self.request) - session = self.request.session + login_form = LoginForm()() try: - session.invalidate() + self.session.invalidate() form_result = login_form.to_python(self.request.params) # form checks for username/password, now we're authenticated headers = _store_user_in_session( @@ -187,13 +186,15 @@ class LoginView(object): # the fly can throw this exception signaling that there's issue # with user creation, explanation should be provided in # Exception itself - session.flash(e, queue='error') + self.session.flash(e, queue='error') return self._get_template_context() @CSRFRequired() @view_config(route_name='logout', request_method='POST') def logout(self): - LoginSession().destroy_user_session() + user = self.request.user + log.info('Deleting session for user: `%s`', user) + self.session.delete() return HTTPFound(url('home')) @HasPermissionAnyDecorator( diff --git a/rhodecode/model/login_session.py b/rhodecode/model/login_session.py deleted file mode 100644 --- a/rhodecode/model/login_session.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2014-2017 RhodeCode GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License, version 3 -# (only), as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# This program is dual-licensed. If you wish to learn more about the -# RhodeCode Enterprise Edition, including its added features, Support services, -# and proprietary license terms, please see https://rhodecode.com/licenses/ - - -""" -Login and cookies session model for RhodeCode -""" - -import logging - -from pylons import session, tmpl_context as c -from rhodecode.model import BaseModel - - -log = logging.getLogger(__name__) - - -class LoginSession(BaseModel): - cls = None - - def destroy_user_session(self): - cur_user = c.rhodecode_user - log.info('Deleting session for user: `%s`', cur_user) - session.delete() -