diff --git a/rhodecode/controllers/admin/my_account.py b/rhodecode/controllers/admin/my_account.py --- a/rhodecode/controllers/admin/my_account.py +++ b/rhodecode/controllers/admin/my_account.py @@ -408,17 +408,10 @@ class MyAccountController(BaseController @auth.CSRFRequired() def my_account_auth_tokens_delete(self): - auth_token = request.POST.get('del_auth_token') - user_id = c.rhodecode_user.user_id - if request.POST.get('del_auth_token_builtin'): - user = User.get(user_id) - if user: - user.api_key = generate_auth_token(user.username) - Session().add(user) - Session().commit() - h.flash(_("Auth token successfully reset"), category='success') - elif auth_token: - AuthTokenModel().delete(auth_token, c.rhodecode_user.user_id) + del_auth_token = request.POST.get('del_auth_token') + + if del_auth_token: + AuthTokenModel().delete(del_auth_token, c.rhodecode_user.user_id) Session().commit() h.flash(_("Auth token successfully deleted"), category='success') diff --git a/rhodecode/controllers/admin/users.py b/rhodecode/controllers/admin/users.py --- a/rhodecode/controllers/admin/users.py +++ b/rhodecode/controllers/admin/users.py @@ -507,16 +507,9 @@ class UsersController(BaseController): h.flash(_("You can't edit this user"), category='warning') return redirect(url('users')) - auth_token = request.POST.get('del_auth_token') - if request.POST.get('del_auth_token_builtin'): - user = User.get(c.user.user_id) - if user: - user.api_key = generate_auth_token(user.username) - Session().add(user) - Session().commit() - h.flash(_("Auth token successfully reset"), category='success') - elif auth_token: - AuthTokenModel().delete(auth_token, c.user.user_id) + del_auth_token = request.POST.get('del_auth_token') + if del_auth_token: + AuthTokenModel().delete(del_auth_token, c.user.user_id) Session().commit() h.flash(_("Auth token successfully deleted"), category='success') diff --git a/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py @@ -649,13 +649,6 @@ class User(Base, BaseModel): return False @property - def builtin_token_roles(self): - roles = [ - UserApiKeys.ROLE_API, UserApiKeys.ROLE_FEED, UserApiKeys.ROLE_HTTP - ] - return map(UserApiKeys._get_role_name, roles) - - @property def ip_addresses(self): ret = UserIpMap.query().filter(UserIpMap.user == self).all() return [x.ip_addr for x in ret] diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -644,13 +644,6 @@ class User(Base, BaseModel): return False @property - def builtin_token_roles(self): - roles = [ - UserApiKeys.ROLE_API, UserApiKeys.ROLE_FEED, UserApiKeys.ROLE_HTTP - ] - return map(UserApiKeys._get_role_name, roles) - - @property def ip_addresses(self): ret = UserIpMap.query().filter(UserIpMap.user == self).all() return [x.ip_addr for x in ret] diff --git a/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako b/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako --- a/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako +++ b/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako @@ -4,35 +4,9 @@

- ${_('Built-in tokens can be used to authenticate with all possible options.')}
${_('Each token can have a role. VCS tokens can be used together with the authtoken auth plugin for git/hg/svn operations.')}

- - - - - - - %if c.user_auth_tokens: %for auth_token in c.user_auth_tokens: diff --git a/rhodecode/templates/admin/users/user_edit_auth_tokens.mako b/rhodecode/templates/admin/users/user_edit_auth_tokens.mako --- a/rhodecode/templates/admin/users/user_edit_auth_tokens.mako +++ b/rhodecode/templates/admin/users/user_edit_auth_tokens.mako @@ -5,30 +5,6 @@
${c.user.api_key}
- ${_('Built-in')} - - % for token in c.user.builtin_token_roles: - - ${token} - - % endfor - ${_('expires')}: ${_('never')} - ${h.secure_form(url('my_account_auth_tokens'),method='delete')} - ${h.hidden('del_auth_token',c.user.api_key)} - ${h.hidden('del_auth_token_builtin',1)} - - ${h.end_form()} -
- - - - - - - %if c.user_auth_tokens: %for auth_token in c.user_auth_tokens: diff --git a/rhodecode/tests/functional/test_admin_my_account.py b/rhodecode/tests/functional/test_admin_my_account.py --- a/rhodecode/tests/functional/test_admin_my_account.py +++ b/rhodecode/tests/functional/test_admin_my_account.py @@ -312,22 +312,6 @@ class TestMyAccountController(TestContro keys = user.extra_auth_tokens assert 1 == len(keys) - def test_my_account_reset_main_auth_token(self): - usr = self.log_user('test_regular2', 'test12') - user = User.get(usr['user_id']) - api_key = user.api_key - response = self.app.get(url('my_account_auth_tokens')) - response.mustcontain(api_key) - response.mustcontain('expires: never') - - response = self.app.post( - url('my_account_auth_tokens'), - {'_method': 'delete', 'del_auth_token_builtin': api_key, - 'csrf_token': self.csrf_token}) - assert_session_flash(response, 'Auth token successfully reset') - response = response.follow() - response.mustcontain(no=[api_key]) - def test_valid_change_password(self, user_util): new_password = 'my_new_valid_password' user = user_util.create_user(password=self.test_user_1_password) diff --git a/rhodecode/tests/functional/test_admin_users.py b/rhodecode/tests/functional/test_admin_users.py --- a/rhodecode/tests/functional/test_admin_users.py +++ b/rhodecode/tests/functional/test_admin_users.py @@ -625,20 +625,3 @@ class TestAdminUsersController(TestContr assert_session_flash(response, 'Auth token successfully deleted') keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all() assert 0 == len(keys) - - def test_reset_main_auth_token(self): - self.log_user() - user = User.get_by_username(TEST_USER_REGULAR_LOGIN) - user_id = user.user_id - api_key = user.api_key - response = self.app.get(url('edit_user_auth_tokens', user_id=user_id)) - response.mustcontain(api_key) - response.mustcontain('expires: never') - - response = self.app.post( - url('edit_user_auth_tokens', user_id=user_id), - {'_method': 'delete', 'del_auth_token_builtin': api_key, - 'csrf_token': self.csrf_token}) - assert_session_flash(response, 'Auth token successfully reset') - response = response.follow() - response.mustcontain(no=[api_key])
${c.user.api_key}
- ${_('Built-in')} - - % for token in c.user.builtin_token_roles: - - ${token} - - % endfor - ${_('expires')}: ${_('never')} - ${h.secure_form(url('edit_user_auth_tokens', user_id=c.user.user_id),method='delete')} - ${h.hidden('del_auth_token',c.user.api_key)} - ${h.hidden('del_auth_token_builtin',1)} - - ${h.end_form()} -