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:
Richie Bendall 2019-06-21 21:03:55 +12:00
parent 47b9749ac9
commit fd54e7198d
No known key found for this signature in database
GPG key ID: 1C6A99DFA9D306FC
5 changed files with 7 additions and 6 deletions

View file

@ -49,8 +49,6 @@ module.exports = (req, res, next) => {
}
);
console.log(res.locals.options);
if (res.locals.options.sha) {
res.setHeader(
'X-note',

View file

@ -20,7 +20,7 @@ module.exports = async (req, res, next) => {
path.join(__dirname, '..', 'users', `${id}.json`),
'utf8'
);
res.locals.user = JSON.parse(data);
res.locals.user = {...res.locals.user, ...JSON.parse(data)};
} 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}`)
return;

View file

@ -48,7 +48,7 @@ module.exports = (req, res) => {
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
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
gravatar = `<img id="gravatar" alt="Profile image" src="https://www.gravatar.com/avatar/${md5(
user.copyright[0].email.trim().toLowerCase()

View file

@ -105,6 +105,4 @@ module.exports = async (req, res) => {
} catch(err) {
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
View file

@ -0,0 +1,5 @@
{
"//1": "Security holding user",
"//2": "This user is being locked incase of potential homepage hijack.",
"locked": true
}