Closed simon86de closed 5 years ago
Hi Simon, I'll admit that I haven't used that, only the simple example from the docs.
I would, however, think that the require
statement should not be within the function. It should actually be outside the module.exports
section of settings.js.
In fact, I think that only the passport.authenticate function should be included in the middleware function. Can you try that and see if it works?
In v2 of uibuilder, I'll be moving the function out of settings.js to a uibuilder specific location, probably ~/.node-red/uibuilder/.middleware.js
I will try to include a more realistic example.
Hi TotallyInformation,
ive got it done by creating a custom node to get access to the "app" object including all the passport stuff. then i could simply add
uibuilder: { middleware: function(req, res, next){ if(req.isAuthenticated()) { //user is authenticated next(); } else { //user isnt authenticated -> redirect to login page res.redirect('/login'); } } }
to the settings.js section. thanks for your advice
Glad you got it working.
im just trying to implement some basic authentication to my uibuilder dashboard. did somebody already get this work? my actual uibuilder section from settings.js looks like:
using this, i get "access denied" without the correct credentials. using the correct credentials, i get:
i think there is something wrong in the logic using
var passport= require('passport') (...)
withinmiddleware: function(req,res,next) {
can someone help me to find the issue?
thanks