Skip to content

Commit d325883

Browse files
authored
Merge pull request #1200 from mathematicalthinking/adminActionButtons
avoid an odd bug
2 parents d41a553 + 57e8492 commit d325883

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

client/src/Containers/Dashboard.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class Dashboard extends Component {
241241

242242
removeAsAdmin = (userId) => {
243243
const { user } = this.props;
244+
console.log('about to force logout', userId, user._id);
244245
socket.emit('FORCE_LOGOUT', userId, user._id);
245246
this._buttonAction(() => API.removeAsAdmin(userId), userId, {
246247
isAdmin: false,
@@ -250,6 +251,7 @@ class Dashboard extends Component {
250251

251252
makeAdmin = (userId) => {
252253
const { user } = this.props;
254+
console.log('about to force logout', userId, user._id);
253255
socket.emit('FORCE_LOGOUT', userId, user._id);
254256
this._buttonAction(() => API.makeAdmin(userId), userId, {
255257
isAdmin: true,

server/sockets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ module.exports = function() {
232232

233233
// implement a tiny bit of authentication: requestor must be an admin
234234
socket.on('FORCE_LOGOUT', async (userId, requestingId) => {
235-
if (!userId) return;
235+
if (!userId || userId === requestingId) return;
236236
const requestor = await controllers.user.getById(requestingId);
237237
if (requestor && requestor.isAdmin) await forceLogout(userId);
238238
});

0 commit comments

Comments
 (0)