##// END OF EJS Templates
login: Move method to store user in session out of login controller....
johbo -
r28:48f65d03 default
parent child Browse files
Show More
@@ -52,12 +52,7 b' from rhodecode.model.user import UserMod'
52 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
53
53
54
54
55 class LoginController(BaseController):
55 def _store_user_in_session(username, remember=False):
56
57 def __before__(self):
58 super(LoginController, self).__before__()
59
60 def _store_user_in_session(self, username, remember=False):
61 user = User.get_by_username(username, case_insensitive=True)
56 user = User.get_by_username(username, case_insensitive=True)
62 auth_user = AuthUser(user.user_id)
57 auth_user = AuthUser(user.user_id)
63 auth_user.set_authenticated()
58 auth_user.set_authenticated()
@@ -86,6 +81,12 b' class LoginController(BaseController):'
86 headers = [('Set-Cookie', session.request['cookie_out'])]
81 headers = [('Set-Cookie', session.request['cookie_out'])]
87 return headers
82 return headers
88
83
84
85 class LoginController(BaseController):
86
87 def __before__(self):
88 super(LoginController, self).__before__()
89
89 def _validate_came_from(self, came_from):
90 def _validate_came_from(self, came_from):
90 if not came_from:
91 if not came_from:
91 return came_from
92 return came_from
@@ -134,7 +135,7 b' class LoginController(BaseController):'
134 session.invalidate()
135 session.invalidate()
135 c.form_result = login_form.to_python(dict(request.POST))
136 c.form_result = login_form.to_python(dict(request.POST))
136 # form checks for username/password, now we're authenticated
137 # form checks for username/password, now we're authenticated
137 headers = self._store_user_in_session(
138 headers = _store_user_in_session(
138 username=c.form_result['username'],
139 username=c.form_result['username'],
139 remember=c.form_result['remember'])
140 remember=c.form_result['remember'])
140 raise self._redirect_to_origin(
141 raise self._redirect_to_origin(
@@ -170,7 +171,7 b' class LoginController(BaseController):'
170 return render('/login.html')
171 return render('/login.html')
171
172
172 if auth_info:
173 if auth_info:
173 headers = self._store_user_in_session(auth_info.get('username'))
174 headers = _store_user_in_session(auth_info.get('username'))
174 raise self._redirect_to_origin(
175 raise self._redirect_to_origin(
175 location=c.came_from, headers=headers)
176 location=c.came_from, headers=headers)
176 return render('/login.html')
177 return render('/login.html')
General Comments 0
You need to be logged in to leave comments. Login now