Note that there are some explanatory texts on larger screens.

plurals
  1. POEveryauth: Check github authentication against a database
    primarykey
    data
    text
    <p>I'm pretty new to node.js and I'm having problem with the everyAuth module.</p> <p>My issue is, I am trying to create an app that lets the user login via github oauth and checks to see if the user is whitelisted in the database. I want to stop the authentication returning true until I check the user is in the whitelist. I have tried several methods to do this but to no avail.</p> <p>Can anyone shed any light?</p> <h3>Calling github method</h3> <pre><code>everyauth.github .appId(conf.github.appId) .appSecret(conf.github.appSecret) .redirectPath('/') .findOrCreateUser (sess, accessToken, accessTokenExtra, ghUser) -&gt; promise = this.Promise() users.findOrCreateByGhData ghUser, accessToken, accessTokenExtra, promise promise; </code></pre> <h3>User class</h3> <pre><code>conf = require '../config' # Mongoose mongoose = require 'mongoose' Schema = mongoose.Schema ObjectId = Schema.ObjectId # Connect mongoose.connect('mongodb://' + conf.db.user + ':' + conf.db.password + '@' + conf.db.url ) # User Schema NewUser = new Schema id : type: Number min: 18 index: true login : type: String ghId : type: Number unique: true date : type: Date default: Date.now # Create Model User = mongoose.model 'NewUser', NewUser exports.findOrCreateByGhData = ( ghData , accessToken, accessTokenExtra, promise ) -&gt; User.find 'ghId': ghData.id , (err, docs) -&gt; if docs.length console.log '=========User===============' console.log docs return promise.fulfill ['Nah its an error'] else console.log '=========No user=============' user = new User() user.login = ghData.login user.ghId = ghData.id user.save ( err ) -&gt; if err throw err console.log 'saved' promise.fulfill user </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload