mirror of
https://github.com/wahyd4/sohub.git
synced 2026-08-09 04:56:09 +10:00
add auth controller
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
var passport = require('passport');
|
||||
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
|
||||
var gcal = require('google-calendar');
|
||||
var util = require('util');
|
||||
|
||||
passport.use(new GoogleStrategy({
|
||||
clientID: '553555458366-bl2e989fn88t27recf2cgp74b3ogcdc1.apps.googleusercontent.com',
|
||||
clientSecret: '8TNPb5ehq-t7g1uiwztaHmC7',
|
||||
callbackURL: "http://127.0.0.1:1337/auth/google"
|
||||
|
||||
},function(accessToken, refreshToken, profile, done) {
|
||||
// asynchronous verification, for effect...
|
||||
console.log(accessToken+"=========");
|
||||
process.nextTick(function () {
|
||||
|
||||
// To keep the example simple, the user's Google profile is returned to
|
||||
// represent the logged-in user. In a typical application, you would want
|
||||
// to associate the Google account with a user record in your database,
|
||||
// and return that user instead.
|
||||
return done(null, profile);
|
||||
});
|
||||
}
|
||||
));
|
||||
|
||||
passport.serializeUser(function (user, done) {
|
||||
done(null, user);
|
||||
});
|
||||
|
||||
passport.deserializeUser(function (obj, done) {
|
||||
done(null, obj);
|
||||
});
|
||||
|
||||
|
||||
var AuthController = {
|
||||
index: passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/userinfo.profile',
|
||||
'https://www.googleapis.com/auth/userinfo.email'] }),
|
||||
|
||||
|
||||
auth: passport.authenticate('google',function(req,res){
|
||||
console.log(res) ;
|
||||
console.log(req);
|
||||
})
|
||||
|
||||
|
||||
|
||||
};
|
||||
module.exports = AuthController;
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = {
|
||||
|
||||
|
||||
// Name of the application (used as default <title>)
|
||||
appName: "Sails Application",
|
||||
appName: "Sohub",
|
||||
|
||||
// Port this Sails application will live on
|
||||
port: process.env.PORT || 1337,
|
||||
|
||||
// The environment the app is deployed in
|
||||
// The environment the app is deployed in
|
||||
// (`development` or `production`)
|
||||
//
|
||||
// In `production` mode, all css and js are bundled up and minified
|
||||
@@ -16,7 +16,7 @@ module.exports = {
|
||||
|
||||
// Logger
|
||||
// Valid `level` configs:
|
||||
//
|
||||
//
|
||||
// - error
|
||||
// - warn
|
||||
// - debug
|
||||
|
||||
+10
-2
@@ -38,7 +38,7 @@ module.exports.routes = {
|
||||
controller: 'message',
|
||||
action: 'viewImage'
|
||||
},
|
||||
'get /message/notice':{
|
||||
'get /message/notice': {
|
||||
controller: 'message',
|
||||
action: 'viewNotice'
|
||||
},
|
||||
@@ -58,9 +58,17 @@ module.exports.routes = {
|
||||
controller: 'weibo',
|
||||
action: 'index'
|
||||
},
|
||||
'get /spike':{
|
||||
'get /spike': {
|
||||
controller: 'message',
|
||||
action: 'spike'
|
||||
},
|
||||
'get /auth': {
|
||||
controller: 'auth',
|
||||
action: 'index'
|
||||
},
|
||||
'get /auth/google': {
|
||||
controller: 'auth',
|
||||
action: 'auth'
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-2
@@ -4,13 +4,16 @@
|
||||
"version": "0.0.1",
|
||||
"description": "social media information hub and aggregator application",
|
||||
"dependencies": {
|
||||
"sails": "0.8.91",
|
||||
"sails": "0.8.93",
|
||||
"sails-mongo": "0.0.3",
|
||||
"optimist": "0.4.0",
|
||||
"wechat": "0.4.4",
|
||||
"nn-oss": "0.0.9",
|
||||
"request": "2.21.0",
|
||||
"weibo": "0.6.9"
|
||||
"weibo": "0.6.9",
|
||||
"google-calendar":"1.0.0",
|
||||
"passport": "> 0.0.0",
|
||||
"passport-google-oauth": ">= 0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
|
||||
Reference in New Issue
Block a user