Browse Source

Follow-up 56f9ce7 - Fixes #5456 - Uploading an avatar is not possible if it was deleted in between.

Dusan Vuckovic 2 months ago
parent
commit
e4d2770ad6
1 changed files with 4 additions and 3 deletions
  1. 4 3
      app/controllers/users_controller.rb

+ 4 - 3
app/controllers/users_controller.rb

@@ -765,9 +765,10 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
     Avatar.remove_one('User', current_user.id, params[:id])
 
     # update user link
-    avatar = Avatar.get_default('User', current_user.id)
-    user = User.find(current_user.id)
-    user.update!(image: avatar.store_hash)
+    if (avatar = Avatar.get_default('User', current_user.id))
+      user = User.find(current_user.id)
+      user.update!(image: avatar.store_hash)
+    end
 
     render json: {}, status: :ok
   end