如何在本地禁用passportjsauthentication

我在我的本地testing我的基于MEAN堆栈的应用程序。 对于使用passportjs的身份validationfunction。

但是,在debugging时,我必须login每次我重新启动服务器。

有没有一个简单的configuration,我可以做,禁用passportjs没有chaning我的代码很多。

我得到它与下面的一段代码工作。 只有下面的更改需要跳过我的应用程序的身份validation。

var isAuthenticated = function (req, res, next) { var isAuthorised = req.isAuthenticated(); // TODO remove followoing on production code // Set user as authorised in local isAuthorised = true; req.user = {}; // id of whichever account you want to load req.user._id = '12345whatever'; if (isAuthorised) { return next(); } // if the user is not authenticated then redirect him to the login page res.redirect('/login'); }; 

希望它可以帮助别人。