mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 13:03:08 +00:00
Add ESLint (#941)
* Add eslint, switch to lint-staged for precommit * Fix all ESLint errors * Update GH workflow to check prettier and eslint
This commit is contained in:
1 parent
0c815fde91
commit
084dc0be08
157 files changed
+737
-666
No files matched your search
@@ -32,7 +32,7 @@ router.get(
|
||||
? parseInt(req.query.length as string)
|
||||
: 255;
|
||||
|
||||
let tokens: ValidRegistrationToken[] = [];
|
||||
const tokens: ValidRegistrationToken[] = [];
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const token = ValidRegistrationToken.create({
|
||||
|
||||
@@ -74,7 +74,7 @@ router.post(
|
||||
"totp_secret",
|
||||
"mfa_enabled",
|
||||
],
|
||||
}).catch((e) => {
|
||||
}).catch(() => {
|
||||
throw FieldErrors({
|
||||
login: {
|
||||
message: req.t("auth:login.INVALID_LOGIN"),
|
||||
|
||||
@@ -27,8 +27,8 @@ router.post(
|
||||
"/",
|
||||
route({ body: "TotpSchema" }),
|
||||
async (req: Request, res: Response) => {
|
||||
const { code, ticket, gift_code_sku_id, login_source } =
|
||||
req.body as TotpSchema;
|
||||
// const { code, ticket, gift_code_sku_id, login_source } =
|
||||
const { code, ticket } = req.body as TotpSchema;
|
||||
|
||||
const user = await User.findOneOrFail({
|
||||
where: {
|
||||
@@ -47,7 +47,7 @@ router.post(
|
||||
});
|
||||
|
||||
if (!backup) {
|
||||
const ret = verifyToken(user.totp_secret!, code);
|
||||
const ret = verifyToken(user.totp_secret || "", code);
|
||||
if (!ret || ret.delta != 0)
|
||||
throw new HTTPError(
|
||||
req.t("auth:login.INVALID_TOTP_CODE"),
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
} from "@fosscord/api";
|
||||
import bcrypt from "bcrypt";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { LessThan, MoreThan } from "typeorm";
|
||||
import { MoreThan } from "typeorm";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
@@ -53,12 +53,12 @@ router.post(
|
||||
let regTokenUsed = false;
|
||||
if (req.get("Referrer") && req.get("Referrer")?.includes("token=")) {
|
||||
// eg theyre on https://staging.fosscord.com/register?token=whatever
|
||||
const token = req.get("Referrer")!.split("token=")[1].split("&")[0];
|
||||
const token = req.get("Referrer")?.split("token=")[1].split("&")[0];
|
||||
if (token) {
|
||||
const regToken = await ValidRegistrationToken.findOne({
|
||||
const regToken = await ValidRegistrationToken.findOneOrFail({
|
||||
where: { token, expires_at: MoreThan(new Date()) },
|
||||
});
|
||||
await ValidRegistrationToken.delete({ token });
|
||||
await regToken.remove();
|
||||
regTokenUsed = true;
|
||||
console.log(
|
||||
`[REGISTER] Registration token ${token} used for registration!`,
|
||||
@@ -71,7 +71,7 @@ router.post(
|
||||
}
|
||||
|
||||
// email will be slightly modified version of the user supplied email -> e.g. protection against GMail Trick
|
||||
let email = adjustEmail(body.email);
|
||||
const email = adjustEmail(body.email);
|
||||
|
||||
// check if registration is allowed
|
||||
if (!regTokenUsed && !register.allowNewRegistration) {
|
||||
|
||||
Reference in new issue
Block a user