summary refs log tree commit diff
path: root/src/routes/auth
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-25 19:46:57 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-25 19:46:57 +0200
commit5dd97905ab03bb50878191bee403b0cb23329636 (patch)
treef2796548c0078ca7e95b59573f27d51711e196fc /src/routes/auth
parent:bug: add event for Message Delete route (diff)
downloadserver-5dd97905ab03bb50878191bee403b0cb23329636.tar.xz
:art: formatting files
Diffstat (limited to 'src/routes/auth')
-rw-r--r--src/routes/auth/login.ts15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/routes/auth/login.ts b/src/routes/auth/login.ts

index 247ee018..5c43db1b 100644 --- a/src/routes/auth/login.ts +++ b/src/routes/auth/login.ts
@@ -25,25 +25,16 @@ router.post( const query: any[] = [{ phone: login }]; if (email) query.push({ email }); - const user = await UserModel.findOne( - { - $or: query, - }, - `user_data.hash id user_settings.locale user_settings.theme` - ).exec(); + const user = await UserModel.findOne({ $or: query }, `user_data.hash id user_settings.locale user_settings.theme`).exec(); if (!user) { - throw FieldErrors({ - login: { message: req.t("auth:login.INVALID_LOGIN"), code: "INVALID_LOGIN" }, - }); + throw FieldErrors({ login: { message: req.t("auth:login.INVALID_LOGIN"), code: "INVALID_LOGIN" } }); } // the salt is saved in the password refer to bcrypt docs const same_password = await bcrypt.compare(password, user.user_data.hash); 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" } }); } const token = await generateToken(user.id);