mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 12:42:44 +01:00
🐛 fix user projection
This commit is contained in:
parent
b76961657e
commit
ce63639090
@ -79,7 +79,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
|
||||
|
||||
if (!register.allowMultipleAccounts) {
|
||||
// TODO: check if fingerprint was eligible generated
|
||||
const exists = await User.findOne({ where: { fingerprints: body.fingerprint } });
|
||||
const exists = await User.findOne({ where: { fingerprints: body.fingerprint }, select: ["id"] });
|
||||
|
||||
if (exists) {
|
||||
throw FieldErrors({
|
||||
@ -109,7 +109,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
|
||||
}
|
||||
|
||||
// check if there is already an account with this email
|
||||
const exists = await User.findOneOrFail({ email: email }).catch((e) => {});
|
||||
const exists = await User.findOne({ email: email });
|
||||
|
||||
if (exists) {
|
||||
throw FieldErrors({
|
||||
|
@ -7,7 +7,7 @@ import { HTTPError } from "lambert-server";
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({}), async (req: Request, res: Response) => {
|
||||
const user = await User.findOneOrFail({ id: req.user_id }); //User object
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] }); //User object
|
||||
let correctpass = true;
|
||||
|
||||
if (user.data.hash) {
|
||||
|
@ -6,7 +6,7 @@ import bcrypt from "bcrypt";
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({}), async (req: Request, res: Response) => {
|
||||
const user = await User.findOneOrFail({ id: req.user_id }); //User object
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] }); //User object
|
||||
let correctpass = true;
|
||||
|
||||
if (user.data.hash) {
|
||||
|
@ -18,7 +18,11 @@ const router = Router();
|
||||
const userProjection: (keyof User)[] = ["relationships", ...PublicUserProjection];
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id }, relations: ["relationships", "relationships.to"] });
|
||||
const user = await User.findOneOrFail({
|
||||
where: { id: req.user_id },
|
||||
relations: ["relationships", "relationships.to"],
|
||||
select: ["relationships"]
|
||||
});
|
||||
|
||||
//TODO DTO
|
||||
const related_users = user.relationships.map((r) => {
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
PublicMember,
|
||||
ChannelType,
|
||||
PublicUser,
|
||||
PrivateUserProjection,
|
||||
} from "@fosscord/util";
|
||||
import { setupListener } from "../listener/listener";
|
||||
import { IdentifySchema } from "../schema/Identify";
|
||||
@ -111,6 +112,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
const user = await User.findOneOrFail({
|
||||
where: { id: this.user_id },
|
||||
relations: ["relationships", "relationships.to"],
|
||||
select: [...PrivateUserProjection, "relationships"],
|
||||
});
|
||||
if (!user) return this.close(CLOSECODES.Authentication_failed);
|
||||
|
||||
|
@ -203,7 +203,7 @@ export class Channel extends BaseClass {
|
||||
|
||||
static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) {
|
||||
recipients = recipients.unique().filter((x) => x !== creator_user_id);
|
||||
const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })) });
|
||||
const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })), select: ["id"] });
|
||||
|
||||
// TODO: check config for max number of recipients
|
||||
if (otherRecipientsUsers.length !== recipients.length) {
|
||||
|
@ -29,6 +29,7 @@ export enum PrivateUserEnum {
|
||||
premium,
|
||||
premium_type,
|
||||
disabled,
|
||||
settings,
|
||||
// locale
|
||||
}
|
||||
export type PrivateUserKeys = keyof typeof PrivateUserEnum | PublicUserKeys;
|
||||
|
Loading…
Reference in New Issue
Block a user