mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Ready to implement account export
This commit is contained in:
parent
f27ffe5d43
commit
cd0e76d017
@ -220,8 +220,18 @@ export class AccountController {
|
|||||||
public static async ExportData(h: RequestHandler) {
|
public static async ExportData(h: RequestHandler) {
|
||||||
await h.needUserPostPassword("password");
|
await h.needUserPostPassword("password");
|
||||||
|
|
||||||
// TODO : implement
|
const data = await AccountHelper.Export(h.getUserId());
|
||||||
h.error(500, "Method not implemented yet.");
|
|
||||||
|
const out: any = {
|
||||||
|
userID: data.userID
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO : continue
|
||||||
|
|
||||||
|
|
||||||
|
h.send(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
20
src/entities/AccountExport.ts
Normal file
20
src/entities/AccountExport.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Account data export
|
||||||
|
*
|
||||||
|
* @author Pierre Hubert
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface AccountExportBuilder {
|
||||||
|
userID: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AccountExport implements AccountExportBuilder {
|
||||||
|
userID: number;
|
||||||
|
|
||||||
|
public constructor(info: AccountExportBuilder) {
|
||||||
|
for (const key in info) {
|
||||||
|
if (info.hasOwnProperty(key))
|
||||||
|
this[key] = info[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import { UserHelper } from "./UserHelper";
|
|||||||
import { time, mysql_date } from "../utils/DateUtils";
|
import { time, mysql_date } from "../utils/DateUtils";
|
||||||
import { NewAccount } from "../entities/NewAccount";
|
import { NewAccount } from "../entities/NewAccount";
|
||||||
import { GeneralSettings, UserPageStatus, LangSettings, SecuritySettings } from "../entities/User";
|
import { GeneralSettings, UserPageStatus, LangSettings, SecuritySettings } from "../entities/User";
|
||||||
|
import { AccountExport } from "../entities/AccountExport";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account helper
|
* Account helper
|
||||||
@ -374,4 +375,20 @@ export class AccountHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export all the data of an account
|
||||||
|
*
|
||||||
|
* @param userID Target user ID
|
||||||
|
*/
|
||||||
|
public static async Export(userID: number) : Promise<AccountExport> {
|
||||||
|
const data = new AccountExport({
|
||||||
|
userID: userID
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// TODO : continue
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user