dashy/services/get-user.js

15 lines
517 B
JavaScript
Raw Normal View History

2023-11-23 07:02:08 +01:00
module.exports = (config, req) => {
try {
if ( config.appConfig.auth.enableHeaderAuth ) {
const userHeader = config.appConfig.auth.headerAuth.userHeader;
2023-11-24 07:11:04 +01:00
const proxyWhitelist = config.appConfig.auth.headerAuth.proxyWhitelist;
if ( proxyWhitelist.includes(req.socket.remoteAddress) ) {
return { "success": true, "user": req.headers[userHeader.toLowerCase()] };
}
2023-11-23 07:02:08 +01:00
}
2023-11-24 07:11:04 +01:00
return {};
2023-11-23 07:02:08 +01:00
} catch (e) {
console.warn("Error get-user: ", e);
return { 'success': false };
}
};