Automatically disconnect from the application upon logging out of Google account

I've successfully set up an express server that uses Google OAuth for user authentication. One interesting challenge I'm facing is how to handle the scenario where a user logs out of Google services (like Gmail) and automatically log them out from my app as well.

app.get('/auth/google/callback', async (req, res) => {
  const code = req.query.code as string
  const { tokens } = await authClient.getToken(code)
  authClient.setCredentials(tokens)
  const { data } = await google.oauth2('v2').userinfo.get({ auth: authClient })
  let user = await prisma.user.findUnique({ where: { googleId: data.id! } })
  if (!user) {
    user = await prisma.user.create({
      data: { googleId: data.id!, displayName: data.name! },
    })
  }
  const token = jwt.sign(user, secret)
  res.cookie('token', token, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 })
  res.redirect(origin)
})

Answer №1

It seems like it may not be feasible. After logging out of Google on a different browser, I noticed that it did not automatically log me out of any websites where I use my Google login credentials.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to transmit data as a reply from a Node.js server to an AJAX client?

Currently, I am utilizing a function to transmit data regarding an HTML element as an object: function postItem(input) { $.ajax({ type: "POST", url: "http://localhost:8080", data: input, success: function(message) { Hconsole.log(&a ...

Update object in a mongodb collection

Currently, I am working on a full stack project using MongoDB, Mongoose, Node.js, and React. In this project, I have a requirement where I need to update the status to true when users click on a specific button. The ID of the button is passed to a route in ...

The process of implementing image validation in PHP, such as checking for size and weight restrictions,

Can someone assist me with inserting an image in PHP, along with validation for size and weight? If the size or weight is incorrect, I need to display an error message. Please provide guidance... PHP script needed... if (isset($_POST['submit']) ...

Why isn't the transparency feature in graphicsmagick working?

Currently, I am utilizing the graphicsmagick npm package which can be found at https://www.npmjs.com/package/gm. In my attempt to write a piece of code similar to the one below, I am struggling to make it function properly with stream. The image file myimg ...

Could someone please explain why my ajax is not functioning properly?

I have been working on an AJAX function to pass input values from one page to another. However, I am facing a challenge where the value is not being passed as expected after redirection. Despite my efforts, I cannot figure out why it's not functionin ...

Are there numerous instances of jQuery references both preceding and following the use of '$.noConflict'?

Managing a large project with thousands of PHP files can be challenging, especially when dealing with conflicting jQuery references that hinder the implementation of a desired plugin. Consider this scenario: <html> <head> ...

The some() method in Javascript with an extra argument

I want to validate if at least one element in an array satisfies a certain condition. The condition is based on a variable. Here's an example of how I'm currently attempting this: function checkCondition(previousValue, index, array) { retur ...

Tips on flipping a texture in Three.js along the horizontal axis

Currently developing a 360 viewer with textures contained within a cylinder. Encountering an issue where textures are appearing horizontally inverted. Although I am aware of the texture.flipY option, I have not been able to locate a texture.flipX function ...

Swap out The div element with the html() method

I'm encountering an issue when trying to swap out a div element with ajax. My goal is to create a start/stop button functionality. The page displays a list of card elements, each with its own button, which are stored in separate html files. work_orde ...

The error message "TypeError: dom.getElementsByTagName is not a function in Node.js" indicates

I have just started learning HTML and web development. I am trying to extract a list of tags from an HTML document but I keep receiving the error message TypeError: dom.getElementsByTagName is not a function. I am making a GET request using axios, then u ...

What steps do I need to take in order to transform an HTML template into a functional Node.JS web

Embarking on my Node.JS journey, I stumbled upon an amazing boilerplate at https://github.com/azouaoui-med/pro-sidebar-template. However, I'm uncertain about how to transform the static html into a dynamic web application. Is there a way someone with ...

A helpful guide on including an image file from a form in a jQuery ajax request

I've been working on a jQuery file upload helper and I'm trying to figure out how to append the File from the form or the entire Form data to the request. In the past, I've used ASP.NET code to handle images from the Request, but when I try ...

Update the text and background colors of all Vuetify components

Hey everyone, I'm trying to figure out how to change the text and background colors of all Vuetify components. I've tried using a custom theme but it's not working as expected. Any suggestions? :) const myCustomLightTheme = { dark: fals ...

Tips for detecting when a browser is closing in a web application that is integrated with a master page

Currently, I am working on a web application that uses a master page. I need to be able to detect when the user is closing the browser so that I can raise an event to clean up session variables. I attempted using the unload JavaScript event, but it seems ...

Tips for transferring an AngularJS file using ExpressJS

Being new to ExpressJS, I have a basic example using EJS, but now I am interested in using AngularJS for DOM manipulation. Both technologies provide tools for manipulating the DOM, so why do some people choose to use them together? This is a concept that c ...

In order to determine if components linked from anchor elements are visible on the screen in Next.js, a thorough examination of the components

Currently, I am in the process of developing my own single-page website using Next.js and Typescript. The site consists of two sections: one (component 1) displaying my name and three anchor elements with a 'sticky' setting for easy navigation, a ...

Unexplainable space or padding issue detected in OwlCarousel grid gallery

There seems to be an unusual gap or margin at the bottom of each row section in this portfolio grid gallery that's running in OwlCarousel. You can view an example here. https://i.stack.imgur.com/NHOBd.png I've spent a lot of time trying to solv ...

What is the process for updating a field within an array in MongoDB by pushing the element if it does not already exist, and updating it if it does already exist

In the process of developing an IT ticketing system, a situation arises where notifications must be sent to users following a ticket whenever a new comment or note is added. The current code successfully adds a new ticket to the list of followed tickets ...

Covering a doughnut shape with a twisting spiral

I want to achieve a hula hoop covered in tape effect using three.js. The 3D model should look similar to the image below. https://i.sstatic.net/lj9cR.jpg I have been able to create the hoop in 3D space using TorusGeometry and pan around, but I am strugg ...

The sonar scanner encountered an error while attempting to parse a file using the espree parser in module mode

While executing sonar-scanner on a node project, I encounter a Failed to parse file issue, as shown below: ERROR: Failed to parse file [file:///home/node-app/somedir/index.js] at line 1: Unexpected token './AddCat' (with espree parser in mod ...