#req.logout is not a functionTypeError: req.logout is not a function

1 messages · Page 1 of 1 (latest)

mystic hemlock
#

Try req.raw.logout()

#

This is one of those things when using fastify with passport. The standard documented approach doesn't work directly because fastify wraps the request object

rough rivet
#

I get this error: ERROR [ExceptionsHandler] req.raw.logout is not a function
TypeError: req.raw.logout is not a function

mystic hemlock
#

Well, was hoping that would do it. You do call the passport middleware functions, right? Initialize and session?

rough rivet
#

fastify.register()?

#

How would it work inside the function?

mystic hemlock
#

app.use(passport.initialize())
app.use(passport.session())

rough rivet
#

const fastifyApp = fastify();
fastifyApp.use() does not recognize it

mystic hemlock
#

Why are you doing fastifyApp? The app above should be the INestApplication

rough rivet
#

because I am working with fastify

mystic hemlock
#

I'm a nest application, right?

rough rivet
#

I don't understand you

mystic hemlock
#

Are you building a nest application, using fastify as the http engine, or is this just fastify?

rough rivet
#

just fastify

mystic hemlock
#

Oh, then I've got no clue. You should be able to use the middleware, but I don't work with fastify directly. This server is generally NestJS support

rough rivet
#

when I place
app.use(passport.initialize())
app.use(passport.session())
I try to access the path where this login gives me the error:
ERROR [ExceptionsHandler] Login sessions require session support. Did you forget to use express-session middleware?

mystic hemlock
#

Well, did you read and understand that error?

#

How are you doing session management?

rough rivet
#

yes and I have just placed
app.register(fastifySession, {
secret: 'asasaasas',
});

app.use(passport.initialize());
app.use(passport.session());

#

correct?

mystic hemlock
#

i don't work with fastify directly. Anytime I do it's through Nest

rough rivet
#

How would the correction be made?

mystic hemlock
#

I guess I'll have to put this in plain English: I don't know because I don't use fastify directly. This server is meant to be support for NestJS

If I had to guess, you need to await the register

rough rivet
#

I managed to fix that piece now when I place:
req.raw.logout();

it tells me :
req#logout requires a callback function
Error: req#logout requires a callback function