diff options
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/routes/auth/login.ts | 11 | ||||
-rw-r--r-- | src/api/routes/auth/register.ts | 14 | ||||
-rw-r--r-- | src/api/routes/users/@me/delete.ts | 14 | ||||
-rw-r--r-- | src/api/routes/users/@me/disable.ts | 12 | ||||
-rw-r--r-- | src/api/routes/users/@me/index.ts | 22 | ||||
-rw-r--r-- | src/api/routes/users/@me/mfa/codes.ts | 10 | ||||
-rw-r--r-- | src/api/routes/users/@me/mfa/totp/enable.ts | 14 |
7 files changed, 77 insertions, 20 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(); diff --git a/src/api/routes/users/@me/delete.ts b/src/api/routes/users/@me/delete.ts index 1d81c2b9..dfc6131b 100644 --- a/src/api/routes/users/@me/delete.ts +++ b/src/api/routes/users/@me/delete.ts @@ -1,8 +1,14 @@ -import { Router, Request, Response } from "express"; -import { Guild, Member, User } from "@fosscord/util"; import { route } from "@fosscord/api"; -import bcrypt from "bcrypt"; -import { HTTPError } from "@fosscord/util"; +import { HTTPError, Member, User } from "@fosscord/util"; +import { Request, Response, Router } from "express"; + +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(); diff --git a/src/api/routes/users/@me/disable.ts b/src/api/routes/users/@me/disable.ts index 4aff3774..477d433c 100644 --- a/src/api/routes/users/@me/disable.ts +++ b/src/api/routes/users/@me/disable.ts @@ -1,7 +1,13 @@ import { User } from "@fosscord/util"; -import { Router, Response, Request } from "express"; -import { route } from "@fosscord/api"; -import bcrypt from "bcrypt"; +import { Request, Response, Router } from "express"; + +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(); diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts index 7d095451..f193a368 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts @@ -1,8 +1,26 @@ import { Router, Request, Response } from "express"; import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors, UserModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -import bcrypt from "bcrypt"; -import { OrmUtils, generateToken } from "@fosscord/util"; +import { + emitEvent, + FieldErrors, + generateToken, + handleFile, + OrmUtils, + PrivateUserProjection, + User, + UserModifySchema, + UserUpdateEvent +} from "@fosscord/util"; +import { Request, Response, Router } from "express"; + +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(); diff --git a/src/api/routes/users/@me/mfa/codes.ts b/src/api/routes/users/@me/mfa/codes.ts index 4224a1c0..e43f6859 100644 --- a/src/api/routes/users/@me/mfa/codes.ts +++ b/src/api/routes/users/@me/mfa/codes.ts @@ -1,7 +1,15 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; import { BackupCode, Config, FieldErrors, generateMfaBackupCodes, MfaCodesSchema, User } from "@fosscord/util"; -import bcrypt from "bcrypt"; +import { Request, Response, Router } from "express"; + +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(); diff --git a/src/api/routes/users/@me/mfa/totp/enable.ts b/src/api/routes/users/@me/mfa/totp/enable.ts index ac668d1d..413291b8 100644 --- a/src/api/routes/users/@me/mfa/totp/enable.ts +++ b/src/api/routes/users/@me/mfa/totp/enable.ts @@ -1,10 +1,16 @@ -import { Router, Request, Response } from "express"; -import { User, generateToken, BackupCode, generateMfaBackupCodes, Config, TotpEnableSchema } from "@fosscord/util"; -import { route } from "@fosscord/api"; -import bcrypt from "bcrypt"; +import { BackupCode, Config, generateMfaBackupCodes, generateToken, TotpEnableSchema, User } from "@fosscord/util"; +import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; import { verifyToken } from 'node-2fa'; +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.post("/", route({ body: "TotpEnableSchema" }), async (req: Request, res: Response) => { |