Skip to content

Node.js based forum software built for the modern web

fix: Topic.isOwner check to handle remote users

Julian Lam0a1ad87d6455
diff --git a/src/topics/user.js b/src/topics/user.js
index d3fbdc91ef..7a2265512c 100644
--- a/src/topics/user.js
+++ b/src/topics/user.js
@@ -1,15 +1,15 @@
'use strict';
const db = require('../database');
+const utils = require('../utils');
module.exports = function (Topics) {
Topics.isOwner = async function (tid, uid) {
- uid = parseInt(uid, 10);
- if (uid <= 0) {
+ if (utils.isNumber(uid) && parseInt(uid, 10) <= 0) {
return false;
}
const author = await Topics.getTopicField(tid, 'uid');
- return author === uid;
+ return String(author) === String(uid);
};
Topics.getUids = async function (tid) {