Changeset - 90af0cdf02d8
[Not reviewed]
default
0 1 0
Søren Løvborg - 9 years ago 2016-09-15 17:42:59
sorenl@unity3d.com
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).
1 file changed with 4 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/my_account.py
Show inline comments
 
@@ -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()
0 comments (0 inline, 0 general)