1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

fix login register + message

This commit is contained in:
Flam3rboy 2021-08-29 16:58:46 +02:00
parent ac84431cc2
commit 6c7abc2c7f
5 changed files with 42 additions and 26 deletions

40
api/package-lock.json generated
View File

@ -28,8 +28,8 @@
"i18next-http-middleware": "^3.1.3",
"i18next-node-fs-backend": "^2.1.3",
"jsonwebtoken": "^8.5.1",
"lambert-server": "^1.2.8",
"missing-native-js-functions": "^1.2.10",
"lambert-server": "^1.2.10",
"missing-native-js-functions": "^1.2.11",
"mongoose": "^5.12.3",
"mongoose-autopopulate": "^0.12.3",
"mongoose-long": "^0.3.2",
@ -74,9 +74,11 @@
"dot-prop": "^6.0.1",
"env-paths": "^2.2.1",
"jsonwebtoken": "^8.5.1",
"missing-native-js-functions": "^1.2.10",
"lambert-server": "^1.2.10",
"missing-native-js-functions": "^1.2.11",
"node-fetch": "^2.6.1",
"patch-package": "^6.4.7",
"pg": "^8.7.1",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.0.2",
"typeorm": "^0.2.37",
@ -6927,16 +6929,16 @@
}
},
"node_modules/lambert-server": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/lambert-server/-/lambert-server-1.2.8.tgz",
"integrity": "sha512-vi/Ku/QudY+WIdGO9bc0qLfVhfuJFWXk1+etesPW1vW29sPbmevLL6IwfvCtw+/MyzRAJLOyCBfQ310a68+2QQ==",
"version": "1.2.10",
"resolved": "https://registry.npmjs.org/lambert-server/-/lambert-server-1.2.10.tgz",
"integrity": "sha512-BHGPmpUrRklFJHPu0vAA8NBewtEd4IX80FRpV4nX9z8kHTUYHqnYHoBeUEWoUmxAeFQvQae1Axk5RQXRQk4VNw==",
"dependencies": {
"body-parser": "^1.19.0",
"chalk": "^4.1.1",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
"helmet": "^4.4.1",
"missing-native-js-functions": "^1.1.8"
"missing-native-js-functions": "^1.2.11"
}
},
"node_modules/lazystream": {
@ -7356,9 +7358,9 @@
}
},
"node_modules/missing-native-js-functions": {
"version": "1.2.10",
"resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.10.tgz",
"integrity": "sha512-sq+oAw/C3OtUyKopLNOf/+U85YNx7db6fy5nVfGVKlGdcV8tX24GjOSkcZeCAnAIjMEnlQBWTr17JXa3OJj22g=="
"version": "1.2.11",
"resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.11.tgz",
"integrity": "sha512-U97IscNBL4Wg9adYjEBT46Hb0Ld5dPT8vbdwFX+TNzGrFQCc4WqoGAZouaLNFwUqxzzHZ9DVg59unwnQyeIIQg=="
},
"node_modules/mixin-deep": {
"version": "1.3.2",
@ -12476,9 +12478,11 @@
"env-paths": "^2.2.1",
"jest": "^27.0.6",
"jsonwebtoken": "^8.5.1",
"missing-native-js-functions": "^1.2.10",
"lambert-server": "^1.2.10",
"missing-native-js-functions": "^1.2.11",
"node-fetch": "^2.6.1",
"patch-package": "^6.4.7",
"pg": "^8.7.1",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.0.2",
"typeorm": "^0.2.37",
@ -17639,16 +17643,16 @@
}
},
"lambert-server": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/lambert-server/-/lambert-server-1.2.8.tgz",
"integrity": "sha512-vi/Ku/QudY+WIdGO9bc0qLfVhfuJFWXk1+etesPW1vW29sPbmevLL6IwfvCtw+/MyzRAJLOyCBfQ310a68+2QQ==",
"version": "1.2.10",
"resolved": "https://registry.npmjs.org/lambert-server/-/lambert-server-1.2.10.tgz",
"integrity": "sha512-BHGPmpUrRklFJHPu0vAA8NBewtEd4IX80FRpV4nX9z8kHTUYHqnYHoBeUEWoUmxAeFQvQae1Axk5RQXRQk4VNw==",
"requires": {
"body-parser": "^1.19.0",
"chalk": "^4.1.1",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
"helmet": "^4.4.1",
"missing-native-js-functions": "^1.1.8"
"missing-native-js-functions": "^1.2.11"
}
},
"lazystream": {
@ -18009,9 +18013,9 @@
}
},
"missing-native-js-functions": {
"version": "1.2.10",
"resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.10.tgz",
"integrity": "sha512-sq+oAw/C3OtUyKopLNOf/+U85YNx7db6fy5nVfGVKlGdcV8tX24GjOSkcZeCAnAIjMEnlQBWTr17JXa3OJj22g=="
"version": "1.2.11",
"resolved": "https://registry.npmjs.org/missing-native-js-functions/-/missing-native-js-functions-1.2.11.tgz",
"integrity": "sha512-U97IscNBL4Wg9adYjEBT46Hb0Ld5dPT8vbdwFX+TNzGrFQCc4WqoGAZouaLNFwUqxzzHZ9DVg59unwnQyeIIQg=="
},
"mixin-deep": {
"version": "1.3.2",

View File

@ -74,8 +74,8 @@
"i18next-http-middleware": "^3.1.3",
"i18next-node-fs-backend": "^2.1.3",
"jsonwebtoken": "^8.5.1",
"lambert-server": "^1.2.8",
"missing-native-js-functions": "^1.2.10",
"lambert-server": "^1.2.10",
"missing-native-js-functions": "^1.2.11",
"mongoose": "^5.12.3",
"mongoose-autopopulate": "^0.12.3",
"mongoose-long": "^0.3.2",

View File

@ -21,7 +21,7 @@ router.post(
async (req: Request, res: Response) => {
const { login, password, captcha_key, undelete } = req.body;
const email = adjustEmail(login);
console.log(req.body, email);
console.log("login", email);
const config = Config.get();

View File

@ -1,5 +1,5 @@
import { Request, Response, Router } from "express";
import { trimSpecial, User, Snowflake, Config } from "@fosscord/util";
import { trimSpecial, User, Snowflake, Config, defaultSettings } from "@fosscord/util";
import bcrypt from "bcrypt";
import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../util/instanceOf";
import "missing-native-js-functions";
@ -182,17 +182,29 @@ router.post(
// if nsfw_allowed is null/undefined it'll require date_of_birth to set it to true/false
const user = await new User({
created_at: new Date(),
username: adjusted_username,
discriminator,
bot: false,
system: false,
desktop: false,
mobile: false,
premium: true,
premium_type: 2,
bio: "",
mfa_enabled: false,
verified: false,
disabled: false,
deleted: false,
email: adjusted_email,
nsfw_allowed: true, // TODO: depending on age
guilds: [],
public_flags: "0",
flags: "0", // TODO: generate
data: {
hash: adjusted_password,
valid_tokens_since: new Date()
}
},
settings: defaultSettings
}).save();
return res.json({ token: await generateToken(user.id) });

View File

@ -11,7 +11,7 @@ export const MessageCreateSchema = {
$content: new Length(String, 0, 2000),
$nonce: String,
$tts: Boolean,
$flags: BigInt,
$flags: String,
$embed: {
$title: new Length(String, 0, 256), //title of embed
$type: String, // type of embed (always "rich" for webhook embeds)
@ -69,7 +69,7 @@ export interface MessageCreateSchema {
content?: string;
nonce?: string;
tts?: boolean;
flags?: bigint;
flags?: string;
embed?: Embed & { timestamp?: string };
allowed_mentions?: {
parse?: string[];