summary refs log tree commit diff
path: root/src/routes/api/v8
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 10:09:32 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 10:09:32 +0100
commitce07018e30cb430393c4a571241dc0c9fa49de24 (patch)
treed6a1db4ce580e97c8e05d0182258fd12196e1016 /src/routes/api/v8
parentmoved utils to server-util (diff)
downloadserver-ce07018e30cb430393c4a571241dc0c9fa49de24.tar.xz
:bug: update imports
Diffstat (limited to 'src/routes/api/v8')
-rw-r--r--src/routes/api/v8/auth/login.ts3
-rw-r--r--src/routes/api/v8/auth/register.ts13
2 files changed, 8 insertions, 8 deletions
diff --git a/src/routes/api/v8/auth/login.ts b/src/routes/api/v8/auth/login.ts

index 9cccbca5..f12c0a64 100644 --- a/src/routes/api/v8/auth/login.ts +++ b/src/routes/api/v8/auth/login.ts
@@ -2,10 +2,9 @@ import { Request, Response, Router } from "express"; import { check, FieldErrors, Length } from "../../../../util/instanceOf"; import bcrypt from "bcrypt"; import jwt from "jsonwebtoken"; +import { db, User } from "discord-server-util"; import Config from "../../../../util/Config"; -import { User } from "../../../../models/User"; import { adjustEmail } from "./register"; -import { db } from "discord-server-util"; const router: Router = Router(); export default router; diff --git a/src/routes/api/v8/auth/register.ts b/src/routes/api/v8/auth/register.ts
index b5800d1f..d53beb74 100644 --- a/src/routes/api/v8/auth/register.ts +++ b/src/routes/api/v8/auth/register.ts
@@ -1,13 +1,10 @@ -import { NextFunction, Request, Response, Router } from "express"; +import { Request, Response, Router } from "express"; import Config from "../../../../util/Config"; -import { db } from "discord-server-util"; +import { db, trimSpecial, User, Snowflake } from "discord-server-util"; import bcrypt from "bcrypt"; import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../../../util/instanceOf"; -import { Snowflake } from "../../../../util/Snowflake"; import "missing-native-js-functions"; -import { User } from "../../../../models/User"; import { generateToken } from "./login"; -import { trimSpecial } from "../../../../util/String"; const router: Router = Router(); @@ -54,6 +51,7 @@ router.post( // discriminator will be randomly generated let discriminator = ""; + // get register Config const { register } = Config.get(); // check if registration is allowed @@ -70,7 +68,7 @@ router.post( }); } - // require invite to register -> for organizations to send invites to their employees + // require invite to register -> e.g. for organizations to send invites to their employees if (register.requireInvite && !invite) { throw FieldErrors({ email: { code: "INVITE_ONLY", message: req.t("auth:register.INVITE_ONLY") }, @@ -78,6 +76,7 @@ router.post( } if (email) { + // replace all dots and chars after +, if its a gmail.com email adjusted_email = adjustEmail(email); // check if there is already an account with this email @@ -164,6 +163,7 @@ router.post( }); } + // constructing final user object const user: User = { id: Snowflake.generate(), created_at: Date.now(), @@ -218,6 +218,7 @@ router.post( }, }; + // insert user into database await db.data.users.push(user); return res.json({ token: await generateToken(user.id) });