improve the register workflow
This commit is contained in:
parent
3a17795ad3
commit
a19f09bef2
@ -1,7 +1,7 @@
|
||||
import {Application, Request, Response} from "express";
|
||||
import {OK} from "http-status-codes";
|
||||
import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable";
|
||||
import Axios, {AxiosError} from "axios";
|
||||
import Axios from "axios";
|
||||
|
||||
export class AdminController {
|
||||
App : Application;
|
||||
@ -27,12 +27,10 @@ export class AdminController {
|
||||
return res.status(e.status || 500).send('An error happened');
|
||||
}
|
||||
|
||||
const teamSlug = response.data.teamSlug;
|
||||
const organizationSlug = response.data.organizationSlug;
|
||||
const worldSlug = response.data.worldSlug;
|
||||
const roomSlug = response.data.roomSlug;
|
||||
return res.status(OK).send({
|
||||
loginUrl: '/@/'+teamSlug+'/'+worldSlug+'/'+roomSlug,
|
||||
});
|
||||
return res.status(OK).send({organizationSlug, worldSlug, roomSlug});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager";
|
||||
import {redirectIfToken} from "./register";
|
||||
|
||||
//CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com');
|
||||
redirectIfToken();
|
||||
let connectionData //todo: do something with this data
|
||||
redirectIfToken().then(res => connectionData = res);
|
||||
|
||||
// Load Jitsi if the environment variable is set.
|
||||
if (JITSI_URL) {
|
||||
|
@ -1,12 +1,29 @@
|
||||
import Axios from "axios";
|
||||
import {API_URL} from "./Enum/EnvironmentVariable";
|
||||
declare let window:Window;
|
||||
declare let history:History;
|
||||
|
||||
export function redirectIfToken() {
|
||||
const match = window.location.toString().match(/\/register\/(.+)/);
|
||||
if (match) {
|
||||
Axios.get(`${API_URL}/register/`+match[1]).then((res) => {
|
||||
window.location = res.data.loginUrl;
|
||||
});
|
||||
//todo: better naming
|
||||
export interface ConnexionData {
|
||||
organizationSlug: string,
|
||||
worldSlug: string,
|
||||
roomSlug: string,
|
||||
}
|
||||
|
||||
export async function redirectIfToken(): Promise<ConnexionData | null> {
|
||||
const match = /\/register\/(.+)/.exec(window.location.toString());
|
||||
if (!match) {
|
||||
return null
|
||||
}
|
||||
let res = null;
|
||||
try {
|
||||
res = await Axios.get(`${API_URL}/register/`+match[1])
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
const organizationSlug = res.data.organizationSlug;
|
||||
const worldSlug = res.data.worldSlug;
|
||||
const roomSlug = res.data.roomSlug;
|
||||
const connexionUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug;
|
||||
history.pushState({}, '', connexionUrl);
|
||||
return {organizationSlug, worldSlug, roomSlug};
|
||||
}
|
Loading…
Reference in New Issue
Block a user