is it possible to use koa-passport without session?
See original GitHub issueHello, just building a restful api for an ios application, i was trying to use json web token to authenticate all my api end points…
ended up hitting a snag
// callback version
passport.use(new LocalStrategy({session: false},
function(username, password, done) {
pool.getConnection(function(connectionError, connection) {
console.log('connection error', connectionError);
const q = {};
q.sql = 'SELECT ?? FROM ?? WHERE ?? = ?';
q.values = ['userPwHash', 'user', 'userName', username];
connection.query(q, function(err, rows) {
console.log('query error', err);
console.log('rows', rows);
if (err) {return done(err); }
if (!rows.length) {
return done(null, false, {message: 'Incorrect username.'});
}
const dbpwhash = rows[0].userPwHash;
bcrypt.compare(password, dbpwhash, function(hashError, match) {
console.log('hasherror', hashError);
if (match) { return done(null, {userName: username}); }
if (!match) {return done(null, false, {message: 'Incorrect password.'}); }
});
connection.close();
});
// pool.end();
});
}
));
Error: Failed to serialize user into session
i was wondering if session is required or how i would go about using an auth token for authentication. thanks again!
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to use the koa-passport.session function in koa ... - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >User Authentication with Passport and Koa - Michael Herman
This tutorial looks at how to set up a local authentication strategy with Node, Koa, and koa-passport, where users can sign up and...
Read more >using koa and passport for authenication - Stack Overflow
I'm using koa and passport trying to implement middleware to prevent access to URIs when not authenticated. var koa = require('koa'); var ...
Read more >Node JS with Passport Authentication simplified - Medium
The primary “Passport JS” library is always required, and is used to maintain session information for authenticated users (i.e. you will import this...
Read more >koa-passport - npm
Passport middleware for Koa. Latest version: 5.0.0, last published: 5 months ago. Start using koa-passport in your project by running `npm i ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hey, this didnt solve my issue though, #124 .
@Globik this is how i did mine, granted it could be cleaner but it works