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
|
* GET /api/foursquare
|
||||||
*/
|
*/
|
||||||
exports.getFoursquare = function(req, res) {
|
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({
|
async.parallel({
|
||||||
trendingVenues: function(callback) {
|
trendingVenues: function(callback) {
|
||||||
var geo = geoip.lookup('4.17.136.0');
|
var geo = geoip.lookup('4.17.136.0');
|
||||||
@ -43,12 +51,8 @@ exports.getFoursquare = function(req, res) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(err, results) {
|
function(err, results) {
|
||||||
if (err) {
|
|
||||||
req.flash('info', err);
|
|
||||||
}
|
|
||||||
res.render('api/foursquare', {
|
res.render('api/foursquare', {
|
||||||
title: 'Foursquare API',
|
title: 'Foursquare API',
|
||||||
message: req.flash('info'),
|
|
||||||
user: req.user,
|
user: req.user,
|
||||||
trendingVenues: results.trendingVenues,
|
trendingVenues: results.trendingVenues,
|
||||||
venueDetail: results.venueDetail,
|
venueDetail: results.venueDetail,
|
||||||
|
@ -1,16 +1,7 @@
|
|||||||
extends ../layout
|
extends ../layout
|
||||||
|
|
||||||
block content
|
block content
|
||||||
if !user.tokens.foursquare
|
.page-header
|
||||||
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
|
|
||||||
h1
|
h1
|
||||||
i.fa.fa-foursquare
|
i.fa.fa-foursquare
|
||||||
| Foursquare APIs
|
| Foursquare APIs
|
||||||
@ -24,7 +15,6 @@ block content
|
|||||||
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/', target='_blank')
|
a.btn.btn-lg.btn-primary(href='https://developer.foursquare.com/docs/', target='_blank')
|
||||||
i.fa.fa-code-fork
|
i.fa.fa-code-fork
|
||||||
| API Endpoints
|
| API Endpoints
|
||||||
|
|
||||||
h3.text-primary Trending Venues
|
h3.text-primary Trending Venues
|
||||||
table.dataTable.table.table-striped.table-bordered
|
table.dataTable.table.table-striped.table-bordered
|
||||||
thead
|
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