mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29: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 { removeHTMLNodes } from "../utils/StringUtils";
|
||||||
import { limit_query } from "./APILimitsController";
|
import { limit_query } from "./APILimitsController";
|
||||||
import { Action } from "../helpers/APILimitsHelper";
|
import { Action } from "../helpers/APILimitsHelper";
|
||||||
|
import { UserController } from "./UserController";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account controller
|
* Account controller
|
||||||
@ -220,10 +221,14 @@ export class AccountController {
|
|||||||
public static async ExportData(h: RequestHandler) {
|
public static async ExportData(h: RequestHandler) {
|
||||||
await h.needUserPostPassword("password");
|
await h.needUserPostPassword("password");
|
||||||
|
|
||||||
|
// Query the database
|
||||||
const data = await AccountHelper.Export(h.getUserId());
|
const data = await AccountHelper.Export(h.getUserId());
|
||||||
|
|
||||||
const out: any = {
|
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 = {
|
const info = {
|
||||||
"userID": user.id,
|
"userID": user.id,
|
||||||
"firstName": user.firstName,
|
"firstName": user.firstName,
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
* @author Pierre Hubert
|
* @author Pierre Hubert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { User } from "./User";
|
||||||
|
|
||||||
export interface AccountExportBuilder {
|
export interface AccountExportBuilder {
|
||||||
userID: number;
|
userID: number;
|
||||||
|
userInfo: User;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AccountExport implements AccountExportBuilder {
|
export class AccountExport implements AccountExportBuilder {
|
||||||
userID: number;
|
userID: number;
|
||||||
|
userInfo: User;
|
||||||
|
|
||||||
public constructor(info: AccountExportBuilder) {
|
public constructor(info: AccountExportBuilder) {
|
||||||
for (const key in info) {
|
for (const key in info) {
|
||||||
|
@ -383,7 +383,8 @@ export class AccountHelper {
|
|||||||
*/
|
*/
|
||||||
public static async Export(userID: number) : Promise<AccountExport> {
|
public static async Export(userID: number) : Promise<AccountExport> {
|
||||||
const data = new AccountExport({
|
const data = new AccountExport({
|
||||||
userID: userID
|
userID: userID,
|
||||||
|
userInfo: await UserHelper.GetUserInfo(userID)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user