passport-local icon indicating copy to clipboard operation
passport-local copied to clipboard

Force authentication without a request?

Open fourpixels opened this issue 10 years ago • 3 comments
trafficstars

Hi there, I've been using passport for a while and now stumbled upon this weird thing - it seems I cannot authenticate an user, from the code, without actually posting all the credentials from web. Is that correct?

The more I browse the authentication strategies and how they work, the more I end up in the passport framework (I use the standard connect style) and I just get here.

So, is there any way I can simply use something like:

passport.authenticate('local', { user: 'username', pass: 'pass', }, function callback(){ });

It seems to me pretty needy. Right now I'm changing my db, and haven't yet updated my login functionality, but I have to drop everything and start doing all those views and stuff, just to get logged in with any user..

Thanks in advance! :)

fourpixels avatar Aug 28 '15 09:08 fourpixels

Just call req.login(user)

Sent from my iPhone

On Aug 28, 2015, at 2:42 AM, fourpixels [email protected] wrote:

Hi there, I've been using passport for a while and now stumbled upon this weird thing - it seems I cannot authenticate an user, from the code, without actually posting all the credentials from web. Is that correct?

The more I browse the authentication strategies and how they work, the more I end up in the passport framework (I use the standard connect style) and I just get here.

So, is there any way I can simply use something like:

passport.authenticate('local', { user: 'username', pass: 'pass', }, function callback(){ }); It seems to me pretty needy. Right now I'm changing my db, and haven't yet updated my login functionality, but I have to drop everything and start doing all those views and stuff, just to get logged in with any user..

Thanks in advance! :)

— Reply to this email directly or view it on GitHub.

jaredhanson avatar Aug 28 '15 14:08 jaredhanson

Well this also implies that I have a request. I guess I'm too lazy because all I wanted is to have logged in user with stored session once I start my server :-$

I guess I'll send an empty request to a page that just uses authenticate or login. Thanks for the help.

fourpixels avatar Aug 28 '15 14:08 fourpixels

How would you have a session without a request?

jaredhanson avatar Aug 28 '15 15:08 jaredhanson