Created
May 28, 2012 21:29
-
-
Save Raynos/2821284 to your computer and use it in GitHub Desktop.
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
var ErrorPage = require("error-page"), | |
errorConfig = require("./error-config.json") | |
module.exports = errorpage | |
function errorpage(req, res, status) { | |
if (Array.isArray(status)) { | |
var page = ErrorPage(req, res, errorConfig) | |
page.apply(page, status) | |
} else { | |
ErrorPage(req, res, errorConfig)(status) | |
} | |
} |
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
var RedSess = require("redsess"), | |
errorPage = require("../../utils/errorPage") | |
module.exports = { | |
isTutor: isTutor | |
} | |
function isTutor(req, res, next) { | |
var session = RedSess(req, res) | |
session.get("auth", handleAuth) | |
function handleAuth(err, auth) { | |
if (err) { | |
return errorPage(req, res, [500, err]) | |
} | |
if (!auth) { | |
return errorPage(req, res, [500, new Error("not logged in")]) | |
} | |
if (!auth.tutor_application) { | |
return errorPage(req, res, [500, new Error("Not authorized")]) | |
} | |
next() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment