Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authoritative will always write response and not error param in callback #72

Open
tokidoki11 opened this issue Aug 27, 2019 · 0 comments

Comments

@tokidoki11
Copy link

tokidoki11 commented Aug 27, 2019

const userController = require('../../controllers/user.controller');
const asyncHandler = require("express-async-handler");
const nodeSSPI = require('node-sspi')
const nodeSSPIObj = new nodeSSPI({
    domain: "XXX",
    authoritative: true
});

module.exports = asyncHandler(async (req, res, next) => {
        nodeSSPIObj.authenticate(req, res, async (err) => {
            if (err)
                throw err;
            if (res.statusCode == null) {
                let userCode = req.connection.user.substring(5, req.connection.user.length);
                let user = await userController.getByCode(userCode);
                if (user == null) throw new Error(`ERROR`);
                req.user = user.toJSON();
                next();
            }
        });
});

From above code I can see the authoritative set either true or false will have the same result
it wont write to err param and will write statusCode to the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant