diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-20 03:17:44 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-20 03:17:44 +0200 |
commit | 3795c677235c74f2debf864183b71f3b76824d99 (patch) | |
tree | d0054af44901f42b4bce8611a1f027605c6dc216 /src/api/routes/auth | |
parent | Drop ajv patch, update setup script (diff) | |
download | server-3795c677235c74f2debf864183b71f3b76824d99.tar.xz |
Add fallback to bcryptjs
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r-- | src/api/routes/auth/login.ts | 11 | ||||
-rw-r--r-- | src/api/routes/auth/register.ts | 14 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/api/routes/auth/login.ts b/src/api/routes/auth/login.ts index 9fc5924d..0fcd43de 100644 --- a/src/api/routes/auth/login.ts +++ b/src/api/routes/auth/login.ts @@ -1,9 +1,16 @@ import { Request, Response, Router } from "express"; import { route } from "@fosscord/api"; -import bcrypt from "bcrypt"; -import { Config, User, generateToken, adjustEmail, FieldErrors, LoginSchema } from "@fosscord/util"; +import { adjustEmail, Config, FieldErrors, generateToken, LoginSchema, User } from "@fosscord/util"; import crypto from "crypto"; +let bcrypt: any; +try { + bcrypt = require("bcrypt"); +} catch { + bcrypt = require("bcryptjs"); + console.log("Warning: using bcryptjs because bcrypt is not installed! Performance will be affected."); +} + const router: Router = Router(); export default router; diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts index 09366a12..7d0f5f57 100644 --- a/src/api/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts @@ -1,8 +1,14 @@ +import { getIpAdress, IPAnalysis, isProxy, route } from "@fosscord/api"; +import { adjustEmail, Config, FieldErrors, generateToken, HTTPError, Invite, RegisterSchema, User } from "@fosscord/util"; import { Request, Response, Router } from "express"; -import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, trimSpecial, RegisterSchema } from "@fosscord/util"; -import { route, getIpAdress, IPAnalysis, isProxy } from "@fosscord/api"; -import bcrypt from "bcrypt"; -import { HTTPError } from "@fosscord/util"; + +let bcrypt: any; +try { + bcrypt = require("bcrypt"); +} catch { + bcrypt = require("bcryptjs"); + console.log("Warning: using bcryptjs because bcrypt is not installed! Performance will be affected."); +} const router: Router = Router(); |