Skip to content

Node.js based forum software built for the modern web

fix: handle missing uid in deprecated socket call

Julian Lamcdaea61136f0
diff --git a/src/socket.io/user/picture.js b/src/socket.io/user/picture.js
index 186ab02835..7de2ef7165 100644
--- a/src/socket.io/user/picture.js
+++ b/src/socket.io/user/picture.js
@@ -8,6 +8,10 @@ const api = require('../../api');
module.exports = function (SocketUser) {
SocketUser.changePicture = async function (socket, data) {
+ if (!socket.uid) {
+ throw new Error('[[error:invalid-uid]]');
+ }
+
websockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/picture');
await api.users.changePicture(socket, data);
};