Merge branch 'fosscord:master' into master

This commit is contained in:
Diego Magdaleno 2021-07-21 14:47:30 -05:00 committed by GitHub
commit 3ae50def52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11333 additions and 741 deletions

12054
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
}, },
"homepage": "https://github.com/fosscord/fosscord-api#readme", "homepage": "https://github.com/fosscord/fosscord-api#readme",
"dependencies": { "dependencies": {
"@fosscord/server-util": "^1.3.29", "@fosscord/server-util": "^1.3.31",
"@types/jest": "^26.0.22", "@types/jest": "^26.0.22",
"@types/json-schema": "^7.0.7", "@types/json-schema": "^7.0.7",
"ajv": "^8.4.0", "ajv": "^8.4.0",

View File

@ -47,15 +47,13 @@ router.post(
const user = await UserModel.findOne( const user = await UserModel.findOne(
{ $or: query }, { $or: query },
{ {
projection: { user_data: {
user_data: { hash: true
hash: true },
}, id: true,
id: true, user_settings: {
user_settings: { locale: true,
locale: true, theme: true
theme: true
}
} }
} }
) )
@ -65,7 +63,7 @@ router.post(
}); });
// the salt is saved in the password refer to bcrypt docs // the salt is saved in the password refer to bcrypt docs
const same_password = await bcrypt.compare(password, user.user_data.hash); const same_password = await bcrypt.compare(password, user.user_data.hash || "");
if (!same_password) { if (!same_password) {
throw FieldErrors({ password: { message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } }); throw FieldErrors({ password: { message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } });
} }