Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
Logout All sessions for an account in express-session, postgresql (connect-pg-simple)

I was wondering how one would create a route to logout all sessions (not just the current one) for a user when using express-session and connect-pg-simple as a session store.

I have the sessions table name set as user_sessions and have previously been able to achieve this using the mysql store on a previous project, which went something like this;

const db = require("../db/connection");

exports.logoutAllDevices = async (user_id) => {
// req.logout(); -- I called this in the controller just before, left it here to show its been called
let logoutAllQuery = 'DELETE FROM user_sessions WHERE JSON_EXTRACT(`data`, "$.passport.user") = $1;';
await db.query(logoutAllQuery, [user_id]);
return;
};

which i found before and the idea was to destroy all sessions related to that user as well as calling the req.logout() function.

However, I can't get any solution to work with this postgres store. Help is appreciated.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda