mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 02:12:40 +01:00
Various fixes for current web client (#875)
* Placeholder member verification endpoint * Welcome screen * Fix types for welcome screen * Try to allow role icons to be removed * Fix typo in genschemas script * Remove left over welcome-screen endpoint * Embedded activities
This commit is contained in:
parent
5d321d2139
commit
6977283e0e
@ -72,6 +72,7 @@
|
||||
localStorage.setItem("UserSettingsStore", JSON.stringify(settings));
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="/assets/checkLocale.js"></script>
|
||||
<script src="/assets/2f2e0c25e45eb2f5a6f1.js"></script>
|
||||
<script src="/assets/006e72c08a4c69cb66fc.js"></script>
|
||||
|
2686
assets/schemas.json
2686
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
||||
"depclean": "node scripts/depclean.js",
|
||||
"depcheck": "node scripts/depcheck.js",
|
||||
"tsnode": "npx ts-node --transpile-only -P tsnode.tsconfig.json src/start.ts",
|
||||
"genschemas": "node scripts/generate_schemas.js",
|
||||
"genschemas": "node scripts/generate_schema.js",
|
||||
"migrate": "cd ../util/ && npm i && node --require ts-node/register node_modules/typeorm/cli.js -f ../util/ormconfig.json migration:run",
|
||||
"postinstall": "patch-package && npx --yes node-git-hooks"
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { Application, Config, FieldErrors, generateToken, handleFile, OrmUtils, trimSpecial, User } from "@fosscord/util";
|
||||
import { Application, Config, FieldErrors, generateToken, handleFile, OrmUtils, trimSpecial, User, HTTPError } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { verifyToken } from "node-2fa";
|
||||
|
||||
const router: Router = Router();
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { BackupCode, generateToken, TotpSchema, User } from "@fosscord/util";
|
||||
import { BackupCode, generateToken, TotpSchema, User, HTTPError } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { verifyToken } from "node-2fa";
|
||||
const router = Router();
|
||||
|
||||
|
30
src/api/routes/auth/verify/view-backup-codes-challenge.ts
Normal file
30
src/api/routes/auth/verify/view-backup-codes-challenge.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
import { FieldErrors, User, BackupCodesChallengeSchema } 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.post("/", route({ body: "BackupCodesChallengeSchema" }), async (req: Request, res: Response) => {
|
||||
const { password } = req.body as BackupCodesChallengeSchema;
|
||||
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] });
|
||||
|
||||
if (!await bcrypt.compare(password, user.data.hash || "")) {
|
||||
throw FieldErrors({ password: { message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } });
|
||||
}
|
||||
|
||||
return res.json({
|
||||
nonce: "NoncePlaceholder",
|
||||
regenerate_nonce: "RegenNoncePlaceholder",
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
14
src/api/routes/guilds/#guild_id/member-verification.ts
Normal file
14
src/api/routes/guilds/#guild_id/member-verification.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
const router = Router();
|
||||
|
||||
router.get("/",route({}), async (req: Request, res: Response) => {
|
||||
// TODO: member verification
|
||||
|
||||
res.status(404).json({
|
||||
message: "Unknown Guild Member Verification Form",
|
||||
code: 10068
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
@ -24,6 +24,8 @@ router.patch("/", route({ body: "GuildUpdateWelcomeScreenSchema", permission: "M
|
||||
if (body.description) guild.welcome_screen.description = body.description;
|
||||
if (body.enabled != null) guild.welcome_screen.enabled = body.enabled;
|
||||
|
||||
await guild.save();
|
||||
|
||||
res.sendStatus(204);
|
||||
});
|
||||
|
||||
|
41
src/api/routes/users/@me/mfa/codes-verification.ts
Normal file
41
src/api/routes/users/@me/mfa/codes-verification.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
import { BackupCode, generateMfaBackupCodes, User, CodesVerificationSchema } from "@fosscord/util";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({ body: "CodesVerificationSchema" }), async (req: Request, res: Response) => {
|
||||
const { key, nonce, regenerate } = req.body as CodesVerificationSchema;
|
||||
|
||||
// TODO: We don't have email/etc etc, so can't send a verification code.
|
||||
// Once that's done, this route can verify `key`
|
||||
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id } });
|
||||
|
||||
var codes: BackupCode[];
|
||||
if (regenerate) {
|
||||
await BackupCode.update(
|
||||
{ user: { id: req.user_id } },
|
||||
{ expired: true }
|
||||
);
|
||||
|
||||
codes = generateMfaBackupCodes(req.user_id);
|
||||
await Promise.all(codes.map(x => x.save()));
|
||||
}
|
||||
else {
|
||||
codes = await BackupCode.find({
|
||||
where: {
|
||||
user: {
|
||||
id: req.user_id,
|
||||
},
|
||||
expired: false,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return res.json({
|
||||
backup_codes: codes.map(x => ({ ...x, expired: undefined })),
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
@ -1,7 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { BackupCode, generateToken, TotpDisableSchema, User } from "@fosscord/util";
|
||||
import { BackupCode, generateToken, TotpDisableSchema, User, HTTPError } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { verifyToken } from "node-2fa";
|
||||
|
||||
const router = Router();
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { BackupCode, Config, generateMfaBackupCodes, generateToken, TotpEnableSchema, User } from "@fosscord/util";
|
||||
import { BackupCode, Config, generateMfaBackupCodes, generateToken, TotpEnableSchema, User, HTTPError } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { verifyToken } from "node-2fa";
|
||||
|
||||
let bcrypt: any;
|
||||
|
@ -241,7 +241,7 @@ export class Guild extends BaseClass {
|
||||
welcome_channels: {
|
||||
description: string;
|
||||
emoji_id?: string;
|
||||
emoji_name: string;
|
||||
emoji_name?: string;
|
||||
channel_id: string;
|
||||
}[];
|
||||
};
|
||||
|
@ -300,7 +300,8 @@ export class Member extends BaseClassWithoutId {
|
||||
joined_at: member.joined_at,
|
||||
presences: [],
|
||||
stage_instances: [],
|
||||
threads: []
|
||||
threads: [],
|
||||
embedded_activities: [],
|
||||
},
|
||||
user_id
|
||||
} as GuildCreateEvent)
|
||||
|
@ -155,6 +155,7 @@ export interface GuildCreateEvent extends Event {
|
||||
presences: never[];
|
||||
stage_instances: never[];
|
||||
threads: never[];
|
||||
embedded_activities: never[];
|
||||
};
|
||||
}
|
||||
|
||||
|
3
src/util/schemas/BackupCodesChallengeSchema.ts
Normal file
3
src/util/schemas/BackupCodesChallengeSchema.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface BackupCodesChallengeSchema {
|
||||
password: string;
|
||||
}
|
5
src/util/schemas/CodesVerificationSchema.ts
Normal file
5
src/util/schemas/CodesVerificationSchema.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface CodesVerificationSchema {
|
||||
key: string;
|
||||
nonce: string;
|
||||
regenerate?: boolean;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
export * from "./ActivitySchema";
|
||||
export * from "./BackupCodesChallengeSchema";
|
||||
export * from "./BanCreateSchema";
|
||||
export * from "./BanModeratorSchema";
|
||||
export * from "./BanRegistrySchema";
|
||||
@ -6,6 +7,7 @@ export * from "./BulkDeleteSchema";
|
||||
export * from "./ChannelModifySchema";
|
||||
export * from "./ChannelPermissionOverwriteSchema";
|
||||
export * from "./ChannelReorderSchema";
|
||||
export * from "./CodesVerificationSchema";
|
||||
export * from "./DmChannelCreateSchema";
|
||||
export * from "./EmojiCreateSchema";
|
||||
export * from "./EmojiModifySchema";
|
||||
@ -42,4 +44,4 @@ export * from "./UserSettingsSchema";
|
||||
export * from "./VanityUrlSchema";
|
||||
export * from "./VoiceStateUpdateSchema";
|
||||
export * from "./WebhookCreateSchema";
|
||||
export * from "./WidgetModifySchema";
|
||||
export * from "./WidgetModifySchema";
|
Loading…
Reference in New Issue
Block a user