[DEV] add in admin user sevice the capability to call the rest service
This commit is contained in:
parent
e1b1649f21
commit
35f15bae61
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user