Show More
@@ -28,6 +28,7 b' from pyramid.httpexceptions import HTTPF' | |||||
28 | from pyramid.view import view_config |
|
28 | from pyramid.view import view_config | |
29 | from recaptcha.client.captcha import submit |
|
29 | from recaptcha.client.captcha import submit | |
30 |
|
30 | |||
|
31 | from rhodecode.authentication.base import authenticate, HTTP_TYPE | |||
31 | from rhodecode.events import UserRegistered |
|
32 | from rhodecode.events import UserRegistered | |
32 | from rhodecode.lib.auth import ( |
|
33 | from rhodecode.lib.auth import ( | |
33 | AuthUser, HasPermissionAnyDecorator, CSRFRequired) |
|
34 | AuthUser, HasPermissionAnyDecorator, CSRFRequired) | |
@@ -115,11 +116,25 b' class LoginView(object):' | |||||
115 | route_name='login', request_method='GET', |
|
116 | route_name='login', request_method='GET', | |
116 | renderer='rhodecode:templates/login.html') |
|
117 | renderer='rhodecode:templates/login.html') | |
117 | def login(self): |
|
118 | def login(self): | |
|
119 | came_from = get_came_from(self.request) | |||
118 | user = self.request.user |
|
120 | user = self.request.user | |
119 |
|
121 | |||
120 | # redirect if already logged in |
|
122 | # redirect if already logged in | |
121 | if user.is_authenticated and not user.is_default and user.ip_allowed: |
|
123 | if user.is_authenticated and not user.is_default and user.ip_allowed: | |
122 |
raise HTTPFound( |
|
124 | raise HTTPFound(came_from) | |
|
125 | ||||
|
126 | # check if we use container plugin, and try to login using it. | |||
|
127 | try: | |||
|
128 | log.debug('Running PRE-AUTH for container based authentication') | |||
|
129 | auth_info = authenticate( | |||
|
130 | '', '', self.request.environ, HTTP_TYPE, skip_missing=True) | |||
|
131 | if auth_info: | |||
|
132 | headers = _store_user_in_session( | |||
|
133 | self.session, auth_info.get('username')) | |||
|
134 | raise HTTPFound(came_from, headers=headers) | |||
|
135 | except UserCreationError as e: | |||
|
136 | log.error(e) | |||
|
137 | self.session.flash(e, queue='error') | |||
123 |
|
138 | |||
124 | return self._get_template_context() |
|
139 | return self._get_template_context() | |
125 |
|
140 | |||
@@ -157,25 +172,8 b' class LoginView(object):' | |||||
157 | # with user creation, explanation should be provided in |
|
172 | # with user creation, explanation should be provided in | |
158 | # Exception itself |
|
173 | # Exception itself | |
159 | session.flash(e, queue='error') |
|
174 | session.flash(e, queue='error') | |
160 |
|
||||
161 | # check if we use container plugin, and try to login using it. |
|
|||
162 | from rhodecode.authentication.base import authenticate, HTTP_TYPE |
|
|||
163 | try: |
|
|||
164 | log.debug('Running PRE-AUTH for container based authentication') |
|
|||
165 | auth_info = authenticate( |
|
|||
166 | '', '', self.request.environ, HTTP_TYPE, skip_missing=True) |
|
|||
167 | except UserCreationError as e: |
|
|||
168 | log.error(e) |
|
|||
169 | session.flash(e, queue='error') |
|
|||
170 | # render login, with flash message about limit |
|
|||
171 | return self._get_template_context() |
|
175 | return self._get_template_context() | |
172 |
|
176 | |||
173 | if auth_info: |
|
|||
174 | headers = _store_user_in_session(auth_info.get('username')) |
|
|||
175 | raise HTTPFound(came_from, headers=headers) |
|
|||
176 |
|
||||
177 | return self._get_template_context() |
|
|||
178 |
|
||||
179 | @CSRFRequired() |
|
177 | @CSRFRequired() | |
180 | @view_config(route_name='logout', request_method='POST') |
|
178 | @view_config(route_name='logout', request_method='POST') | |
181 | def logout(self): |
|
179 | def logout(self): |
General Comments 0
You need to be logged in to leave comments.
Login now