Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

442
Views
What is the optimal code that can respond to the logout request with 205 status code? (node.js / express / POST / signout )

As in the title, when I request a logout, I have tried logic in various ways to respond to the 205 status code, but I can not write the appropriate logic.

  1. signin.js -
  • If the user ID or password received at the login request is perfectly consistent with the information stored in the database, the 'ok' message and status code 200 must be included in the response. ✓

  • If the user ID or password received at the login request is i- nvalid, the 'invalid user' message and status code 404 must be included in the response. ✓

  • If you succeed in logining, you must forward JWT tokens to cookies. ✓

  1. singout.js -
  • POST /signout / You must respond with the 205 status code when you request a logout. ?
// server/controllers/users/signout.js

module.exports = (req, res) => {
//TODO: ## Create logout logic ##
  res.status(500).send();
};


// server/controllers/users/signin.js
[ This is what I wrote about the signin logic ]

const { request } = require('express');
const { user } = require('../../models');
const { generateAccessToken, sendAccessToken } = require('../tokenFunctions');

module.exports = async (req, res) => {
//TODO: Deliver tokens after user authentication through login information

  await user
    .findOne({
      where: { email: req.body.email, password: req.body.password },
    })
    .then((userObject) => {
      if (userObject) {
        res.append('set-cookie', 'jwt');
        res.status(200).json({ message: 'ok' });
      } else {
        res.status(404).send('invalid user');
      }
    });
};


// server/tokenFuntions/index.js
require('dotenv').config();
const { sign, verify } = require('jsonwebtoken');

module.exports = {
  generateAccessToken: (data) => {
//TODO: sign with token
  },
  sendAccessToken: (res, accessToken) => {
//TODO: Deliver JWT tokens to cookies.
    res.json({ message: 'ok' });
  },
  isAuthorized: (req) => {
//TODO: Verify by receiving JWT token information.
//HINT: Receive JWT token information and verify it.Return the decoded payload using the verify function of the Jsonwebtoken library. 
  },
};


// server/controllers/users/index.js
module.exports = {
  auth: require('./users/auth'),
  signup: require('./users/signup'),
  signin: require('./users/signin'),
  signout: require('./users/signout'),
};

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!