From 1ddf2249c4d2b77909f8d5513d55235e91454502 Mon Sep 17 00:00:00 2001 From: V3L0C1T13S Date: Mon, 4 Dec 2023 13:01:12 -0500 Subject: [PATCH] fix(models): Update ResponseLogin.from_quark() --- src/common/models/models/auth/index.ts | 33 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/common/models/models/auth/index.ts b/src/common/models/models/auth/index.ts index f73dc02..01ed04d 100644 --- a/src/common/models/models/auth/index.ts +++ b/src/common/models/models/auth/index.ts @@ -4,24 +4,35 @@ import { SessionInfo, } from "revolt-api"; import { decodeTime } from "ulid"; +import { toSnowflake } from "@reflectcord/common/models"; +import { systemUserID } from "@reflectcord/common/rvapi"; import { QuarkConversion } from "../../QuarkConversion"; import { LoginSchema, MFALoginSchema, UserSession } from "../../../sparkle"; import { toCompatibleISO } from "../../../utils/date"; -export type APILoginResponse = { +export type APIMFALoginResponse = { + user_id: string, + ticket: string | undefined, // MFA ticket + sms: boolean | undefined, + mfa: boolean | undefined, + backup: boolean, + totp: boolean, + webauthn: null, // FIXME: what type is this? +} + +export type APISuccessfulLoginResponse = { token: string | null, settings: any, - ticket?: string | undefined, // MFA ticket - sms?: boolean | undefined, - mfa?: boolean | undefined, + user_settings: any, } +export type APILoginResponse = APISuccessfulLoginResponse | APIMFALoginResponse; + export const ResponseLogin: QuarkConversion = { async to_quark(login) { - const { token } = login; - + // TODO: mfa return { - token: token ?? "", + token: "token" in login ? login.token ?? "" : "", result: "Success", user_id: "", // FIXME, name: "", @@ -34,11 +45,13 @@ export const ResponseLogin: QuarkConversion