mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-27 15:07:42 +00:00
fix: Append user params instead of overwrite to fix empty file bugs
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
parent
47b9749ac9
commit
fd54e7198d
5 changed files with 7 additions and 6 deletions
|
|
@ -49,8 +49,6 @@ module.exports = (req, res, next) => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(res.locals.options);
|
|
||||||
|
|
||||||
if (res.locals.options.sha) {
|
if (res.locals.options.sha) {
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
'X-note',
|
'X-note',
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ module.exports = async (req, res, next) => {
|
||||||
path.join(__dirname, '..', 'users', `${id}.json`),
|
path.join(__dirname, '..', 'users', `${id}.json`),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
res.locals.user = JSON.parse(data);
|
res.locals.user = {...res.locals.user, ...JSON.parse(data)};
|
||||||
} catch ({code, message}) {
|
} catch ({code, message}) {
|
||||||
res.code(500).send(`An internal error occurred - open an issue on https://github.com/remy/mit-license with the following information: ${message}`)
|
res.code(500).send(`An internal error occurred - open an issue on https://github.com/remy/mit-license with the following information: ${message}`)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ module.exports = (req, res) => {
|
||||||
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
||||||
user.email.trim().toLowerCase()
|
user.email.trim().toLowerCase()
|
||||||
)}" />`;
|
)}" />`;
|
||||||
} else if (user.copyright && typeof user.copyright[0] === 'object' && user.gravatar) {
|
} else if (typeof user.copyright[0] === 'object' && user.gravatar) {
|
||||||
// Supports multi-user format
|
// Supports multi-user format
|
||||||
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
|
||||||
user.copyright[0].email.trim().toLowerCase()
|
user.copyright[0].email.trim().toLowerCase()
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,4 @@ module.exports = async (req, res) => {
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
res.status(500).send(`Unable to create new user - please send a pull request on https://github.com/remy/mit-license`)
|
res.status(500).send(`Unable to create new user - please send a pull request on https://github.com/remy/mit-license`)
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
5
users/mit-license.json
Normal file
5
users/mit-license.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"//1": "Security holding user",
|
||||||
|
"//2": "This user is being locked incase of potential homepage hijack.",
|
||||||
|
"locked": true
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue