Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAUTH with Sequelize and Postgresql #1654

Closed
smirciat opened this issue Feb 23, 2016 · 1 comment
Closed

OAUTH with Sequelize and Postgresql #1654

smirciat opened this issue Feb 23, 2016 · 1 comment

Comments

@smirciat
Copy link

My setup chooses Sequelize for data modelling, and it is linked to a Postgresql database. The scaffolding generated this portion of the user model in /server/api/user/user.model.js :

provider: DataTypes.STRING,
    salt: DataTypes.STRING,
    facebook: DataTypes.TEXT,
    twitter: DataTypes.TEXT,
    google: DataTypes.TEXT,
    github: DataTypes.TEXT

To make Oauth work in this confirmation, I had to change the datatypes for facebook, google, twitter, and github to

  twitter: DataTypes.JSON

. Since the generator had already created the table model in Postgresq;, I had to either drop that table or manually alter it. I assume this might cause problems with other Sequelize databases, since JSON is in Postgres but not some others. Not sure if it would cause more harm then good to change the generator template in this manner, but it worked for my purpose.

Secondly, I had to manually modify each of the /server/auth/twitter/passport.js type files to match proper sequelize syntax.

function(token, tokenSecret, profile, done) {
    User.find({where: {
      'twitter.id_str': profile.id }
    })

in place of the original syntax (mongoose style)

function(token, tokenSecret, profile, done) {
    User.find({
      'twitter.id_str': profile.id 
    })

Hope this helps someone else!

smirciat pushed a commit to smirciat/generator-angular-fullstack that referenced this issue Feb 25, 2016
Awk34 pushed a commit that referenced this issue Feb 25, 2016
Awk34 pushed a commit that referenced this issue Feb 25, 2016
@Awk34 Awk34 closed this as completed in 221f7a4 Feb 25, 2016
@shaharyar123
Copy link

shaharyar123 commented Mar 1, 2017

i am facing the OAUTH issue when i assign datatype JSON to facebook and google. my database is mysql, getting this error :

Server failed to start due to error: SequelizeDatabaseError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'JSON, twitterJSON,googleJSON,

if i set datatype : text or string then it works but i cant query on them. How to store in JSON datatype in MySql ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants