##// END OF EJS Templates
users: use two distinct actions for user password reset....
marcink -
r3378:f96b7591 default
parent child Browse files
Show More
@@ -280,8 +280,12 b' def admin_routes(config):'
280 280 pattern='/users/{user_id:\d+}/delete',
281 281 user_route=True)
282 282 config.add_route(
283 name='user_force_password_reset',
284 pattern='/users/{user_id:\d+}/password_reset',
283 name='user_enable_force_password_reset',
284 pattern='/users/{user_id:\d+}/password_reset_enable',
285 user_route=True)
286 config.add_route(
287 name='user_disable_force_password_reset',
288 pattern='/users/{user_id:\d+}/password_reset_disable',
285 289 user_route=True)
286 290 config.add_route(
287 291 name='user_create_personal_repo_group',
@@ -59,8 +59,6 b' def route_path(name, params=None, **kwar'
59 59 ADMIN_PREFIX + '/users/{user_id}/update',
60 60 'user_delete':
61 61 ADMIN_PREFIX + '/users/{user_id}/delete',
62 'user_force_password_reset':
63 ADMIN_PREFIX + '/users/{user_id}/password_reset',
64 62 'user_create_personal_repo_group':
65 63 ADMIN_PREFIX + '/users/{user_id}/create_repo_group',
66 64
@@ -599,12 +599,9 b' class UsersView(UserAppView):'
599 599 @HasPermissionAllDecorator('hg.admin')
600 600 @CSRFRequired()
601 601 @view_config(
602 route_name='user_force_password_reset', request_method='POST',
602 route_name='user_enable_force_password_reset', request_method='POST',
603 603 renderer='rhodecode:templates/admin/users/user_edit.mako')
604 def user_force_password_reset(self):
605 """
606 toggle reset password flag for this user
607 """
604 def user_enable_force_password_reset(self):
608 605 _ = self.request.translate
609 606 c = self.load_default_context()
610 607
@@ -612,19 +609,41 b' class UsersView(UserAppView):'
612 609 c.user = self.db_user
613 610
614 611 try:
615 old_value = c.user.user_data.get('force_password_change')
616 c.user.update_userdata(force_password_change=not old_value)
612 c.user.update_userdata(force_password_change=True)
613
614 msg = _('Force password change enabled for user')
615 audit_logger.store_web('user.edit.password_reset.enabled',
616 user=c.rhodecode_user)
617
618 Session().commit()
619 h.flash(msg, category='success')
620 except Exception:
621 log.exception("Exception during password reset for user")
622 h.flash(_('An error occurred during password reset for user'),
623 category='error')
624
625 raise HTTPFound(h.route_path('user_edit_advanced', user_id=user_id))
617 626
618 if old_value:
619 msg = _('Force password change disabled for user')
620 audit_logger.store_web(
621 'user.edit.password_reset.disabled',
622 user=c.rhodecode_user)
623 else:
624 msg = _('Force password change enabled for user')
625 audit_logger.store_web(
626 'user.edit.password_reset.enabled',
627 user=c.rhodecode_user)
627 @LoginRequired()
628 @HasPermissionAllDecorator('hg.admin')
629 @CSRFRequired()
630 @view_config(
631 route_name='user_disable_force_password_reset', request_method='POST',
632 renderer='rhodecode:templates/admin/users/user_edit.mako')
633 def user_disable_force_password_reset(self):
634 _ = self.request.translate
635 c = self.load_default_context()
636
637 user_id = self.db_user_id
638 c.user = self.db_user
639
640 try:
641 c.user.update_userdata(force_password_change=False)
642
643 msg = _('Force password change disabled for user')
644 audit_logger.store_web(
645 'user.edit.password_reset.disabled',
646 user=c.rhodecode_user)
628 647
629 648 Session().commit()
630 649 h.flash(msg, category='success')
@@ -102,7 +102,8 b' function registerRCRoutes() {'
102 102 pyroutes.register('user_edit_global_perms_update', '/_admin/users/%(user_id)s/edit/global_permissions/update', ['user_id']);
103 103 pyroutes.register('user_update', '/_admin/users/%(user_id)s/update', ['user_id']);
104 104 pyroutes.register('user_delete', '/_admin/users/%(user_id)s/delete', ['user_id']);
105 pyroutes.register('user_force_password_reset', '/_admin/users/%(user_id)s/password_reset', ['user_id']);
105 pyroutes.register('user_enable_force_password_reset', '/_admin/users/%(user_id)s/password_reset_enable', ['user_id']);
106 pyroutes.register('user_disable_force_password_reset', '/_admin/users/%(user_id)s/password_reset_disable', ['user_id']);
106 107 pyroutes.register('user_create_personal_repo_group', '/_admin/users/%(user_id)s/create_repo_group', ['user_id']);
107 108 pyroutes.register('edit_user_auth_tokens_delete', '/_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']);
108 109 pyroutes.register('edit_user_ssh_keys', '/_admin/users/%(user_id)s/edit/ssh_keys', ['user_id']);
@@ -143,7 +143,7 b''
143 143 <div class="select">
144 144 ${c.form['repo_landing_commit_ref'].render(css_class='medium', oid='repo_landing_commit_ref')|n}
145 145 ${c.form.render_error(request, c.form['repo_landing_commit_ref'])|n}
146 <p class="help-block">${_('Default commit for files page, downloads, full text search index and readme')}</p>
146 <p class="help-block">${_('The default commit for file pages, downloads, full text search index, and README generation.')}</p>
147 147 </div>
148 148 </div>
149 149
@@ -35,15 +35,23 b''
35 35 <h3 class="panel-title">${_('Force Password Reset')}</h3>
36 36 </div>
37 37 <div class="panel-body">
38 ${h.secure_form(h.route_path('user_force_password_reset', user_id=c.user.user_id), request=request)}
38 ${h.secure_form(h.route_path('user_disable_force_password_reset', user_id=c.user.user_id), request=request)}
39 39 <div class="field">
40 40 <button class="btn btn-default" type="submit">
41 <i class="icon-lock"></i>
42 %if c.user.user_data.get('force_password_change'):
43 ${_('Disable forced password reset')}
44 %else:
45 ${_('Enable forced password reset')}
46 %endif
41 <i class="icon-unlock"></i> ${_('Disable forced password reset')}
42 </button>
43 </div>
44 <div class="field">
45 <span class="help-block">
46 ${_("Clear the forced password change flag.")}
47 </span>
48 </div>
49 ${h.end_form()}
50
51 ${h.secure_form(h.route_path('user_enable_force_password_reset', user_id=c.user.user_id), request=request)}
52 <div class="field">
53 <button class="btn btn-default" type="submit" onclick="return confirm('${_('Confirm to enable forced password change')}');">
54 <i class="icon-lock"></i> ${_('Enable forced password reset')}
47 55 </button>
48 56 </div>
49 57 <div class="field">
@@ -52,6 +60,7 b''
52 60 </span>
53 61 </div>
54 62 ${h.end_form()}
63
55 64 </div>
56 65 </div>
57 66
General Comments 0
You need to be logged in to leave comments. Login now