# HG changeset patch # User Søren Løvborg # Date 2016-09-15 17:42:59 # Node ID 90af0cdf02d809f3acae4e701184f3202167e174 # Parent d1ed15ef87149b728837050c4ec7da45266da5da cleanup: don't check if currently logged-in user exists Don't check if the currently logged-in User exists. Every request runs in a database transaction; if the object existed at the start, it still exists (unless we add a way for a user to delete themselves). diff --git a/kallithea/controllers/admin/my_account.py b/kallithea/controllers/admin/my_account.py --- a/kallithea/controllers/admin/my_account.py +++ b/kallithea/controllers/admin/my_account.py @@ -255,14 +255,11 @@ class MyAccountController(BaseController def my_account_api_keys_delete(self): api_key = request.POST.get('del_api_key') - user_id = self.authuser.user_id if request.POST.get('del_api_key_builtin'): - user = User.get(user_id) - if user is not None: - user.api_key = generate_api_key() - Session().add(user) - Session().commit() - h.flash(_("API key successfully reset"), category='success') + user = User.get(self.authuser.user_id) + user.api_key = generate_api_key() + Session().commit() + h.flash(_("API key successfully reset"), category='success') elif api_key: ApiKeyModel().delete(api_key, self.authuser.user_id) Session().commit()