@@ -239,20 +239,22 @@ class Dashboard extends Component {
239239 isSuspended : false ,
240240 } ) ;
241241
242- removeAsAdmin = ( userId ) => {
243- const { user } = this . props ;
244- console . log ( 'about to force logout' , userId , user . _id ) ;
245- socket . emit ( 'FORCE_LOGOUT' , userId , user . _id ) ;
242+ removeAsAdmin = ( userId , details ) => {
243+ if ( this . _isOkToForceLogout ( details ) ) {
244+ const { user } = this . props ;
245+ socket . emit ( 'FORCE_LOGOUT' , userId , user . _id ) ;
246+ }
246247 this . _buttonAction ( ( ) => API . removeAsAdmin ( userId ) , userId , {
247248 isAdmin : false ,
248249 socketId : null ,
249250 } ) ;
250251 } ;
251252
252253 makeAdmin = ( userId ) => {
253- const { user } = this . props ;
254- console . log ( 'about to force logout' , userId , user . _id ) ;
255- socket . emit ( 'FORCE_LOGOUT' , userId , user . _id ) ;
254+ if ( this . _isOkToForceLogout ( details ) ) {
255+ const { user } = this . props ;
256+ socket . emit ( 'FORCE_LOGOUT' , userId , user . _id ) ;
257+ }
256258 this . _buttonAction ( ( ) => API . makeAdmin ( userId ) , userId , {
257259 isAdmin : true ,
258260 socketId : null ,
@@ -336,12 +338,13 @@ class Dashboard extends Component {
336338 } ;
337339
338340 const iconActions = [ ] ;
339- if ( details . socketId && ! details . doForceLogout )
340- iconActions . push ( forceLogoutAction ) ;
341+ if ( this . _isOkToForceLogout ( details ) ) iconActions . push ( forceLogoutAction ) ;
341342 if ( ! isSelf ) iconActions . push ( suspendReinstateAction , makeRemoveAdmin ) ;
342343 return iconActions ;
343344 } ;
344345
346+ _isOkToForceLogout = ( user ) => user . socketId && ! user . doForceLogout ;
347+
345348 render ( ) {
346349 const { match, user } = this . props ;
347350 const {
@@ -410,7 +413,7 @@ class Dashboard extends Component {
410413 < Button
411414 data-testid = { manageUserAction }
412415 click = { ( ) => {
413- this [ manageUserAction ] ( userToManage . _id ) ;
416+ this [ manageUserAction ] ( userToManage . _id , userToManage ) ;
414417 } }
415418 m = { 5 }
416419 >
0 commit comments