Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
railwayjs environment config
- var items = ["facebook", "github", "twitter", "instagram"]
- if (!everyauth.loggedIn)
h2 Not Authenticated
each item in items
a(href='/auth/' + item)
span Connect with <span style="text-transform: capitalize">!{item}</span><br />
- else
h2 Authenticated
#user-id Logged in with `user.id` #{user.id} - aka `everyauth.user.id` #{everyauth.user.id}
- if (everyauth.facebook)
h3 Facebook User Data
p= JSON.stringify(everyauth.facebook.user)
- if (everyauth.twitter)
h3 Twitter User Data
p= JSON.stringify(everyauth.twitter.user)
- if (everyauth.github)
h3 GitHub User Data
p= JSON.stringify(everyauth.github.user)
- if (everyauth.instagram)
h3 Instagram User Data
p= JSON.stringify(everyauth.instagram.user)
h3
a(href='/logout') Logout
var express = require('express');
var mongooseAuth = require('mongoose-auth');
require('./config/mongoose_oauth');
app.configure(function() {
var cwd;
cwd = process.cwd();
app.set('views', cwd + '/app/views');
app.set('view engine', 'jade');
app.use(express.static(cwd + '/public', {
maxAge: 86400000
}));
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({
secret: 'secret'
}));
// MAKE SURE THIS IS COMMENTED OUT, otherwise it will produce errors that are mostly nonsensical
//app.use(app.router)
app.use(express.methodOverride());
app.use(mongooseAuth.middleware());
});
mongooseAuth.helpExpress(app);
var mongoose = require('mongoose')
, Schema = mongoose.Schema;
var conf = require('./oauth_providers');
var UserSchema = new Schema({})
, User;
mongooseAuth = require('mongoose-auth');
UserSchema.plugin(mongooseAuth, {
everymodule: {
everyauth: {
User: function() {
return User;
}
}
},
facebook: {
everyauth: {
myHostname: 'http://local.host:3001',
appId: conf.fb.appId,
appSecret: conf.fb.appSecret,
redirectPath: '/'
}
},
twitter: {
everyauth: {
myHostname: 'http://local.host:3001',
consumerKey: conf.twit.consumerKey,
consumerSecret: conf.twit.consumerSecret,
redirectPath: '/'
}
},
github: {
everyauth: {
myHostname: 'http://local.host:3001',
appId: conf.github.appId,
appSecret: conf.github.appSecret,
redirectPath: '/'
}
}
});
User = mongoose.model('User', UserSchema);
module.exports["User"] = mongoose.model("User");
module.exports["User"].modelName = "User";
module.exports = {
fb: {
appId: '111565172259433',
appSecret: '85f7e0a0cc804886180b887c1f04a3c1'
},
twit: {
consumerKey: 'JLCGyLzuOK1BjnKPKGyQ',
consumerSecret: 'GNqKfPqtzOcsCtFbGTMqinoATHvBcy1nzCTimeA9M0'
},
github: {
appId: '11932f2b6d05d2a5fa18',
appSecret: '2603d1bc663b74d6732500c1e9ad05b0f4013593'
},
instagram: {
clientId: 'be147b077ddf49368d6fb5cf3112b9e0',
clientSecret: 'b65ad83daed242c0aa059ffae42feddd'
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment