Created a separate page to which user gets redirected if no token is present (foursquare)
This commit is contained in:
@ -21,6 +21,14 @@ exports.getApi = function(req, res) {
|
||||
* GET /api/foursquare
|
||||
*/
|
||||
exports.getFoursquare = function(req, res) {
|
||||
if (!req.user.tokens.foursquare) {
|
||||
return res.render('api/unauthorized', {
|
||||
title: 'Foursquare API',
|
||||
provider: 'Foursquare',
|
||||
user: req.user
|
||||
});
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
trendingVenues: function(callback) {
|
||||
var geo = geoip.lookup('4.17.136.0');
|
||||
@ -43,12 +51,8 @@ exports.getFoursquare = function(req, res) {
|
||||
}
|
||||
},
|
||||
function(err, results) {
|
||||
if (err) {
|
||||
req.flash('info', err);
|
||||
}
|
||||
res.render('api/foursquare', {
|
||||
title: 'Foursquare API',
|
||||
message: req.flash('info'),
|
||||
user: req.user,
|
||||
trendingVenues: results.trendingVenues,
|
||||
venueDetail: results.venueDetail,
|
||||
|
@ -1,16 +1,7 @@
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
if !user.tokens.foursquare
|
||||
h3
|
||||
i.fa.fa-shield
|
||||
| Authorization Required
|
||||
a(href='/auth/foursquare')
|
||||
.label.label-primary.label-block
|
||||
h2
|
||||
i.fa.fa-qrcode
|
||||
| Get Foursquare Token
|
||||
else
|
||||
.page-header
|
||||
h1
|
||||
i.fa.fa-foursquare
|
||||
| Foursquare APIs
|
||||
@ -24,7 +15,6 @@ block content
|
||||
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/', target='_blank')
|
||||
i.fa.fa-code-fork
|
||||
| API Endpoints
|
||||
|
||||
h3.text-primary Trending Venues
|
||||
table.dataTable.table.table-striped.table-bordered
|
||||
thead
|
||||
|
9
views/api/unauthorized.jade
Normal file
9
views/api/unauthorized.jade
Normal file
@ -0,0 +1,9 @@
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
h3
|
||||
i.fa.fa-lock
|
||||
| Authorization Required
|
||||
a.btn.btn-lg.btn-primary(href='/auth/foursquare')
|
||||
i.fa.fa-qrcode
|
||||
| Get #{provider} Token
|
Reference in New Issue
Block a user