'use strict';

const auth = require('basic-auth');
const { User } = require('../lib/server-impl.js');

function basicAuthentication(app) {
    app.use('/api/admin/', (req, res, next) => {
        const credentials = auth(req);

        if (credentials) {
            // you will need to do some verification of credentials here.
            const user = new User({ email: `${credentials.name}@domain.com` });
            req.user = user;
            next();
        } else {
            return res
                .status('401')
                .set({ 'WWW-Authenticate': 'Basic realm="example"' })
                .send({
                    message: 'You must be authenticated to use Unleash',
                    path: '/custom/login',
                });
        }
    });

    app.use((req, res, next) => {
        // Updates active sessions every hour
        req.session.nowInHours = Math.floor(Date.now() / 3600e3);
        next();
    });
}

module.exports = basicAuthentication;

@@ -618,143 +618,23 @@
 end(
-%7B%0A                    message: 'You must be authenticated to use Unleash',%0A                    path: '/custom/login',%0A                %7D
+'access denied'
 );%0A 

Update basic-auth-hook.js