simplified mapUrl parsing

This commit is contained in:
arp 2020-10-08 18:51:24 +02:00
parent f542b117a8
commit 4af46b1b3f
6 changed files with 93 additions and 73 deletions

View file

@ -17,10 +17,20 @@ class ConnectionManager {
private authToken:string|null = null;
private userUuid: string|null = null;
//todo: get map infos from url in anonym case
public async init(): Promise<void> {
let organizationMemberToken = null;
let teamSlug = null;
let mapSlug = null;
const match = /\/register\/(.+)/.exec(window.location.toString());
const organizationMemberToken = match ? match[1] : null;
this.initPromise = Axios.post(`${API_URL}/login`, {organizationMemberToken}).then(res => res.data);
if (match) {
organizationMemberToken = match[1];
} else {
const match = /\/_\/(.+)\/(.+)/.exec(window.location.toString());
teamSlug = match ? match[1] : null;
mapSlug = match ? match[2] : null;
}
this.initPromise = Axios.post(`${API_URL}/login`, {organizationMemberToken, teamSlug, mapSlug}).then(res => res.data);
const data = await this.initPromise
this.authToken = data.authToken;
this.userUuid = data.userUuid;