onLogout( ) event handler issue

Thank you Yisrael, my mistake was that all the code was on a frontend side, and with no any supress options. Now after your help it works, thanks again!!!

I’ll share an updated code below, hope it could be helpful for others.

Frontend code (masterPage.js)

import { authentication } from 'wix-members';
import {loginState} from 'backend/data.jsw';

import wixUsers from 'wix-users';

let user = wixUsers.currentUser;
let userId = user.id;


$w.onReady(function() {

    authentication.onLogout(()=> {
    
        loginState(userId)
        
    })
    
})

Backend code (data.jsw)

const Users = 'Users';

export function loginState(userId) {

  wixData
        .query(Users)
        .eq('userId', userId)
        .limit(1)
        .find()
    .then( (results) => {

    let res = results.items
    let length = res.length   

    if (length > 0) {

      let id = res[0]._id

      let options = {
      "suppressAuth": true,
      "suppressHooks": true
      };

    wixData.get(Users, id, options)
    .then( (item) => {
      item.isLoggedIn = false;
      wixData.update(Users, item);
    } )
    .catch( (err) => {
      let errorMsg = err;
    } );

  }

  })

}