Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41af78d
commit 371abba
Showing
1 changed file
with
27 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,29 +12,35 @@ var meta = require('../meta'); | |
var helpers = {}; | ||
|
||
helpers.notAllowed = function(req, res, error) { | ||
if (req.uid) { | ||
if (res.locals.isAPI) { | ||
res.status(403).json({ | ||
path: req.path.replace(/^\/api/, ''), | ||
loggedIn: !!req.uid, error: error, | ||
title: '[[global:403.title]]' | ||
}); | ||
} else { | ||
res.status(403).render('403', { | ||
path: req.path, | ||
loggedIn: !!req.uid, error: error, | ||
title: '[[global:403.title]]' | ||
}); | ||
} | ||
} else { | ||
if (res.locals.isAPI) { | ||
req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); | ||
res.status(401).json('not-authorized'); | ||
plugins.fireHook('filter:helpers.notAllowed', { | ||
req: req, | ||
res: res, | ||
error: error | ||
}, function(err, data) { | ||
if (req.uid) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
barisusakli
Member
|
||
if (res.locals.isAPI) { | ||
res.status(403).json({ | ||
path: req.path.replace(/^\/api/, ''), | ||
loggedIn: !!req.uid, error: error, | ||
title: '[[global:403.title]]' | ||
}); | ||
} else { | ||
res.status(403).render('403', { | ||
path: req.path, | ||
loggedIn: !!req.uid, error: error, | ||
title: '[[global:403.title]]' | ||
}); | ||
} | ||
} else { | ||
req.session.returnTo = nconf.get('relative_path') + req.url; | ||
res.redirect(nconf.get('relative_path') + '/login'); | ||
if (res.locals.isAPI) { | ||
req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); | ||
res.status(401).json('not-authorized'); | ||
} else { | ||
req.session.returnTo = nconf.get('relative_path') + req.url; | ||
res.redirect(nconf.get('relative_path') + '/login'); | ||
} | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
helpers.redirect = function(res, url) { | ||
|
Shouldn't it be getting req, res, and error from the data object?