diff --git a/src/controllers/AccountController.ts b/src/controllers/AccountController.ts index 1eb31c9..42e8fa7 100644 --- a/src/controllers/AccountController.ts +++ b/src/controllers/AccountController.ts @@ -5,6 +5,7 @@ import { NewAccount } from "../entities/NewAccount"; import { removeHTMLNodes } from "../utils/StringUtils"; import { limit_query } from "./APILimitsController"; import { Action } from "../helpers/APILimitsHelper"; +import { UserController } from "./UserController"; /** * Account controller @@ -220,10 +221,14 @@ export class AccountController { public static async ExportData(h: RequestHandler) { await h.needUserPostPassword("password"); + // Query the database const data = await AccountHelper.Export(h.getUserId()); const out: any = { - userID: data.userID + userID: data.userID, + + // General account information + advanced_info: await UserController.UserToAPI(data.userInfo, h, true) }; diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 801160f..020c792 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -68,7 +68,7 @@ export class UserController { } - private static async UserToAPI(user : User, h: RequestHandler, advanced: boolean = false) : Promise { + public static async UserToAPI(user : User, h: RequestHandler, advanced: boolean = false) : Promise { const info = { "userID": user.id, "firstName": user.firstName, diff --git a/src/entities/AccountExport.ts b/src/entities/AccountExport.ts index 10b4082..268c7bb 100644 --- a/src/entities/AccountExport.ts +++ b/src/entities/AccountExport.ts @@ -4,12 +4,16 @@ * @author Pierre Hubert */ +import { User } from "./User"; + export interface AccountExportBuilder { userID: number; + userInfo: User; } export class AccountExport implements AccountExportBuilder { userID: number; + userInfo: User; public constructor(info: AccountExportBuilder) { for (const key in info) { diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index e87b1ad..e57c2a2 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -383,7 +383,8 @@ export class AccountHelper { */ public static async Export(userID: number) : Promise { const data = new AccountExport({ - userID: userID + userID: userID, + userInfo: await UserHelper.GetUserInfo(userID) })