Merge pull request #303 from thecodingmachine/fixsendrights
Fixing the way rights are sent to the admin
This commit is contained in:
commit
3710c3cb7d
@ -1,14 +1,25 @@
|
|||||||
export class RoomIdentifier {
|
export class RoomIdentifier {
|
||||||
public anonymous: boolean;
|
public readonly anonymous: boolean;
|
||||||
public id:string
|
public readonly id:string
|
||||||
|
public readonly organizationSlug: string|undefined;
|
||||||
|
public readonly worldSlug: string|undefined;
|
||||||
|
public readonly roomSlug: string|undefined;
|
||||||
constructor(roomID: string) {
|
constructor(roomID: string) {
|
||||||
if (roomID.startsWith('_/')) {
|
if (roomID.startsWith('_/')) {
|
||||||
this.anonymous = true;
|
this.anonymous = true;
|
||||||
} else if(roomID.startsWith('@/')) {
|
} else if(roomID.startsWith('@/')) {
|
||||||
this.anonymous = false;
|
this.anonymous = false;
|
||||||
|
|
||||||
|
const match = /@\/([^/]+)\/([^/]+)\/(.+)/.exec(roomID);
|
||||||
|
if (!match) {
|
||||||
|
throw new Error('Could not extract info from "'+roomID+'"');
|
||||||
|
}
|
||||||
|
this.organizationSlug = match[1];
|
||||||
|
this.worldSlug = match[2];
|
||||||
|
this.roomSlug = match[3];
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Incorrect room ID: '+roomID);
|
throw new Error('Incorrect room ID: '+roomID);
|
||||||
}
|
}
|
||||||
this.id = roomID; //todo: extract more data from the id (like room slug, organization name, etc);
|
this.id = roomID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,8 @@ class AdminApi {
|
|||||||
return Promise.reject('No admin backoffice set!');
|
return Promise.reject('No admin backoffice set!');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//todo: send more specialized data instead of the whole id
|
|
||||||
const res = await Axios.get(ADMIN_API_URL+'/api/member/is-granted-access',
|
const res = await Axios.get(ADMIN_API_URL+'/api/member/is-granted-access',
|
||||||
{ headers: {"Authorization" : `${ADMIN_API_TOKEN}`}, params: {memberId, roomIdentifier: roomIdentifier.id} }
|
{ headers: {"Authorization" : `${ADMIN_API_TOKEN}`}, params: {memberId, organizationSlug: roomIdentifier.organizationSlug, worldSlug: roomIdentifier.worldSlug, roomSlug: roomIdentifier.roomSlug} }
|
||||||
)
|
)
|
||||||
return !!res.data;
|
return !!res.data;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -66,7 +66,7 @@ export class Room {
|
|||||||
this.instance = match[1];
|
this.instance = match[1];
|
||||||
return this.instance;
|
return this.instance;
|
||||||
} else {
|
} else {
|
||||||
const match = /_\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
|
const match = /@\/([^/]+)\/([^/]+)\/.+/.exec(this.id);
|
||||||
if (!match) throw new Error('Could not extract instance from "'+this.id+'"');
|
if (!match) throw new Error('Could not extract instance from "'+this.id+'"');
|
||||||
this.instance = match[1]+'/'+match[2];
|
this.instance = match[1]+'/'+match[2];
|
||||||
return this.instance;
|
return this.instance;
|
||||||
|
Loading…
Reference in New Issue
Block a user