Switching ban by IP to be world specific
This commit is contained in:
parent
5954ded195
commit
4df200c6c0
@ -116,12 +116,12 @@ class AdminApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async verifyBanUser(organizationMemberToken: string, ipAddress: string, room: string): Promise<AdminBannedData> {
|
async verifyBanUser(organizationMemberToken: string, ipAddress: string, organization: string, world: string): Promise<AdminBannedData> {
|
||||||
if (!ADMIN_API_URL) {
|
if (!ADMIN_API_URL) {
|
||||||
return Promise.reject('No admin backoffice set!');
|
return Promise.reject('No admin backoffice set!');
|
||||||
}
|
}
|
||||||
//todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case.
|
//todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case.
|
||||||
return Axios.get(ADMIN_API_URL + '/api/check-moderate-user/' + ipAddress + '/' + organizationMemberToken + '/room/' + room,
|
return Axios.get(ADMIN_API_URL + '/api/check-moderate-user/'+organization+'/'+world+'?ipAddress='+ipAddress+'&token='+organizationMemberToken,
|
||||||
{headers: {"Authorization": `${ADMIN_API_TOKEN}`}}
|
{headers: {"Authorization": `${ADMIN_API_TOKEN}`}}
|
||||||
).then((data) => {
|
).then((data) => {
|
||||||
return data.data;
|
return data.data;
|
||||||
|
@ -76,8 +76,17 @@ class JWTTokenManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private verifyBanUser(userUuid: string, ipAddress: string, room: string): Promise<AdminBannedData> {
|
private verifyBanUser(userUuid: string, ipAddress: string, room: string): Promise<AdminBannedData> {
|
||||||
const world = room.split('/')[1]; //check by world
|
const parts = room.split('/');
|
||||||
return adminApi.verifyBanUser(userUuid, ipAddress, world).then((data: AdminBannedData) => {
|
if (parts.length < 3 || parts[0] !== '@') {
|
||||||
|
return Promise.resolve({
|
||||||
|
is_banned: false,
|
||||||
|
message: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const organization = parts[1];
|
||||||
|
const world = parts[2];
|
||||||
|
return adminApi.verifyBanUser(userUuid, ipAddress, organization, world).then((data: AdminBannedData) => {
|
||||||
if (data && data.is_banned) {
|
if (data && data.is_banned) {
|
||||||
throw new Error('User was banned');
|
throw new Error('User was banned');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user