[DEV] add in admin user sevice the capability to call the rest service

This commit is contained in:
Edouard DUPIN 2023-01-08 12:21:34 +01:00
parent e1b1649f21
commit 35f15bae61

View File

@ -137,6 +137,75 @@ export class AdminUserService {
});
}
setAdmin(userId: number, state: boolean): Promise<void> {
let body = state;
return new Promise((resolve, reject) => {
this.http
.requestJson({
server: 'karso',
endPoint: `users/${userId}/set_admin`,
requestType: HTTPRequestModel.POST,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body,
})
.then((response: ModelResponseHttp) => {
resolve();
})
.catch((error: any) => {
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
});
});
}
setBlocked(userId: number, state: boolean): Promise<void> {
let body = state;
return new Promise((resolve, reject) => {
this.http
.requestJson({
server: 'karso',
endPoint: `users/${userId}/set_blocked`,
requestType: HTTPRequestModel.POST,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body,
})
.then((response: ModelResponseHttp) => {
resolve();
})
.catch((error: any) => {
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
});
});
}
createUsers(email: string, login: string, password: string): Promise<any> {
let body = {
email,
login,
password: sha512(password)
};
return new Promise((resolve, reject) => {
this.http
.requestJson({
server: 'karso',
endPoint: 'users/create_new_user',
requestType: HTTPRequestModel.POST,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body,
})
.then((response: ModelResponseHttp) => {
resolve(response.data);
})
.catch((error: any) => {
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
});
});
}
create(login: string, email: string, password: string) {
return this.createSha(login, email, sha512(password));
}