##// END OF EJS Templates
audit-logs: store user agent for login/logout actions.
marcink -
r1702:d464b1a6 default
parent child Browse files
Show More
@@ -171,8 +171,10 b' class LoginView(BaseAppView):'
171 audit_user = audit_logger.UserWrap(
171 audit_user = audit_logger.UserWrap(
172 username=self.request.params.get('username'),
172 username=self.request.params.get('username'),
173 ip_addr=self.request.remote_addr)
173 ip_addr=self.request.remote_addr)
174 audit_logger.store(action='user.login.success', user=audit_user,
174 action_data = {'user_agent': self.request.user_agent}
175 commit=True)
175 audit_logger.store(
176 action='user.login.success', action_data=action_data,
177 user=audit_user, commit=True)
176
178
177 raise HTTPFound(c.came_from, headers=headers)
179 raise HTTPFound(c.came_from, headers=headers)
178 except formencode.Invalid as errors:
180 except formencode.Invalid as errors:
@@ -188,8 +190,10 b' class LoginView(BaseAppView):'
188 audit_user = audit_logger.UserWrap(
190 audit_user = audit_logger.UserWrap(
189 username=self.request.params.get('username'),
191 username=self.request.params.get('username'),
190 ip_addr=self.request.remote_addr)
192 ip_addr=self.request.remote_addr)
191 audit_logger.store(action='user.login.failure', user=audit_user,
193 action_data = {'user_agent': self.request.user_agent}
192 commit=True)
194 audit_logger.store(
195 action='user.login.failure', action_data=action_data,
196 user=audit_user, commit=True)
193 return render_ctx
197 return render_ctx
194
198
195 except UserCreationError as e:
199 except UserCreationError as e:
@@ -205,8 +209,11 b' class LoginView(BaseAppView):'
205 def logout(self):
209 def logout(self):
206 auth_user = self._rhodecode_user
210 auth_user = self._rhodecode_user
207 log.info('Deleting session for user: `%s`', auth_user)
211 log.info('Deleting session for user: `%s`', auth_user)
208 audit_logger.store(action='user.logout', user=auth_user,
212
209 commit=True)
213 action_data = {'user_agent': self.request.user_agent}
214 audit_logger.store(
215 action='user.logout', action_data=action_data,
216 user=auth_user, commit=True)
210 self.session.delete()
217 self.session.delete()
211 return HTTPFound(url('home'))
218 return HTTPFound(url('home'))
212
219
@@ -355,8 +362,10 b' class LoginView(BaseAppView):'
355 # Display success message and redirect.
362 # Display success message and redirect.
356 self.session.flash(msg, queue='success')
363 self.session.flash(msg, queue='success')
357
364
365 action_data = {'email': user_email,
366 'user_agent': self.request.user_agent}
358 audit_logger.store(action='user.password.reset_request',
367 audit_logger.store(action='user.password.reset_request',
359 action_data={'email': user_email},
368 action_data=action_data,
360 user=self._rhodecode_user, commit=True)
369 user=self._rhodecode_user, commit=True)
361 return HTTPFound(self.request.route_path('reset_password'))
370 return HTTPFound(self.request.route_path('reset_password'))
362
371
General Comments 0
You need to be logged in to leave comments. Login now