Comments (8)
Hi @geekhack
can you provide me your source code to help me allocate your problem exactly?
from sails-social-auth-example.
Hi @stefanbuck
my user model:
module.exports = {
adapter: 'mysql',
tableName: 'user',
migrate: 'safe',
schema: true, //this only saves the available atributes and discards the rest that are not available
attributes : {
provider: {
type:'STRING',
unique:true
},
uid: 'INTEGER',
name: 'STRING',
email: 'STRING',
firstname: 'STRING',
lastname: 'STRING',
autoPK:false
}
};
//my middleware.js verifyHandler
var verifyHandler = function (token, tokenSecret, profile, done) {
process.nextTick(function () {
User.findOne({uid: parseInt(profile.id)}).done(function (err, user) {
if (user) {
//return done(null, user);
console.log(profile);
//this returns the object ..okay
} else {
var data = {
provider: profile.provider,
uid: profile.id,
name: profile.displayName
};
if(profile.emails && profile.emails[0] && profile.emails[0].value) {
data.email = profile.emails[0].value;
}
if(profile.name && profile.name.givenName) {
data.firstname = profile.name.givenName;
}
if(profile.name && profile.name.familyName) {
data.lastname = profile.name.familyName;
}
User.create(data).done(function (err, user) {
return done(err, user);
});
}
});
});
};
from sails-social-auth-example.
@geekhack it's really strange. Your code works fine on my machine with a little modification in the if statement block. But i'm not sure if this is your problem. You musst call the return done(null, user);
to send the result back to the controller.
I use the following version of sails and mySQL:
sails: 0.9.16
mySQL: 5.5.25
from sails-social-auth-example.
Inserting the data into the datastore is not the issue.I have tried your suggesting and is still duplicating records.I have created a repo here.You can have a look at it and advise.
https://github.com/geekhack/sailsfB.git
from sails-social-auth-example.
@stefanbuck I have used the method User.find().where({uid: profile.id}).done and seems to find the user, now the only issue is that it cannot serialize the session(seems to be a sessions issue)..Any idea on mysql sessions?
from sails-social-auth-example.
I tried to reproduce your issue without success!? This is how my mySQL dump looks like.
INSERT INTO `Sessions` (`sid`, `expires`, `json`, `id`, `createdAt`, `updatedAt`) VALUES
('tIReU0cKMHj4Ku07Vv-uD4XY', 1397682103, '{"cookie":{"originalMaxAge":900000,"expires":"2014-04-16T21:01:43.438Z","httpOnly":true,"path":"/"},"passport":{"user":1393946}}', 1, '2014-04-16 22:46:38', '2014-04-16 22:46:43');
from sails-social-auth-example.
Its ok.thanks.I am sure there is a way,I will figure it out and get back to you. :)
from sails-social-auth-example.
Hey @stefanbuck .I solved the issue.It was not about session store,but about the data type in the mysql database.Just use varchar on the datatype column and make sure you change your user model attribute(uid) to string.Finally ensure you have changed the middleware findOne method to:
User.findOne({uid: profile.id}).done(function (err, user) {
Omitting parseInt.
Thanks and Cheers!
from sails-social-auth-example.
Related Issues (20)
- auth/google/callback never gets called HOT 1
- Google plus and facebook detail HOT 2
- Authentication for socket requests HOT 1
- mongo auth fails in sails_0.10 branch HOT 1
- sails 0.10.x HOT 4
- Failed to login more than one person. HOT 1
- Do you know how to add basic Email and Password auth HOT 1
- Return URL problem when using path.join HOT 2
- Google authentication callback never triggers HOT 4
- Twitter auth stopped working HOT 2
- change call back url HOT 1
- Instructions for adding new Strategies HOT 1
- How to store user ids and api keys in config/env/production.js? HOT 1
- Cancelling the facebook permissions request causes 500 error HOT 1
- Getting username from the req.user HOT 1
- Errors for missing policies in api/policies/ HOT 1
- use req.session in config/express.js ? HOT 3
- Cannot find module 'express/node_modules/cookie' HOT 2
- how can i enable sail's default CRUD operations? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sails-social-auth-example.