mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Get advanced user info
This commit is contained in:
parent
cd0e76d017
commit
4004d5fd77
@ -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)
|
||||
};
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ export class UserController {
|
||||
}
|
||||
|
||||
|
||||
private static async UserToAPI(user : User, h: RequestHandler, advanced: boolean = false) : Promise<Object> {
|
||||
public static async UserToAPI(user : User, h: RequestHandler, advanced: boolean = false) : Promise<Object> {
|
||||
const info = {
|
||||
"userID": user.id,
|
||||
"firstName": user.firstName,
|
||||
|
@ -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) {
|
||||
|
@ -383,7 +383,8 @@ export class AccountHelper {
|
||||
*/
|
||||
public static async Export(userID: number) : Promise<AccountExport> {
|
||||
const data = new AccountExport({
|
||||
userID: userID
|
||||
userID: userID,
|
||||
userInfo: await UserHelper.GetUserInfo(userID)
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user