Skip to content

Commit

Permalink
Add channel verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed Jun 26, 2015
1 parent b768363 commit f0e5b23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 3 additions & 4 deletions lib/ChangeTip.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ ChangeTip.prototype.post = function(url, params, cb) {
params = {};
}

console.log('posting...');

rest.post( self.base + url , {
headers: {
'Authorization': 'Bearer ' + self.token
'Authorization': 'Bearer ' + self.token,
'Content-Type': 'application/json'
},
data: params
data: JSON.stringify(params)
}).on('complete', function(data) {
cb( null , data );
}).on('error', cb );
Expand Down
17 changes: 10 additions & 7 deletions soundtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ app.post('/tips', requireLogin , function(req, res, next) {
}, function(err, results) {
var result = err || results;

console.log('result:', result);


if (result.errors) return res.send(result);

res.render('partials/announcement', {
Expand Down Expand Up @@ -602,8 +599,8 @@ if (config.changetip && config.changetip.id && config.changetip.secret) {
clientID: config.changetip.id,
clientSecret: config.changetip.secret,
//callbackURL: ((config.app.safe) ? 'https://' : 'http://') + config.app.host + '/auth/changetip/callback',
callbackURL: 'https://soundtrack.io/auth/changetip/callback',
//callbackURL: 'http://localhost.localdomain:13000/auth/changetip/callback',
//callbackURL: 'https://soundtrack.io/auth/changetip/callback',
callbackURL: 'http://localhost.localdomain:13000/auth/changetip/callback',
passReqToCallback: true
}, function(req, accessToken, refreshToken, profile, done) {

Expand Down Expand Up @@ -634,8 +631,14 @@ if (config.changetip && config.changetip.id && config.changetip.secret) {

app.get('/auth/changetip', redirectSetup , passport.authenticate('changetip') );
app.get('/auth/changetip/callback', passport.authenticate('changetip') , function(req, res) {
req.flash('info', 'Congrats! You can now send tips to anyone who has configured their ChangeTip account.');
res.redirect('/');
console.log( req.user._id );
req.changetip.post('verify-channel-user', {
channel_uid: req.user._id.toString()
}, function(err, results) {
console.log('verify:', err , results );
req.flash('info', 'Congrats! You can now send tips to anyone who has configured their ChangeTip account.');
res.redirect('/');
});
});

}
Expand Down

0 comments on commit f0e5b23

Please sign in to comment.