Files
old-psihologija/helpers/auth.js
2019-05-24 15:42:45 +02:00

23 lines
581 B
JavaScript

'use strict';
const basicAuth = require('express-basic-auth');
function myAuthorizer(username, password) {
if (!process.env.BASIC_AUTH_USERNAME || !process.env.BASIC_AUTH_PASSWORD){
return false;
}
const userMatches = basicAuth.safeCompare(username, process.env.BASIC_AUTH_USERNAME);
const passwordMatches = basicAuth.safeCompare(password, process.env.BASIC_AUTH_PASSWORD);
return userMatches & passwordMatches
}
function getUnauthorizedResponse(req) {
return 'Forbidden';
}
module.exports = {
myAuthorizer,
getUnauthorizedResponse,
};