Merge branch 'develop' of github.com:thecodingmachine/workadventure
This commit is contained in:
@@ -29,8 +29,10 @@ class ConnectionManager {
|
||||
});
|
||||
}
|
||||
|
||||
public loadOpenIDScreen() {
|
||||
localUserStore.setAuthToken(null);
|
||||
/**
|
||||
* @return Promise<void>
|
||||
*/
|
||||
public loadOpenIDScreen(): Promise<void> {
|
||||
const state = localUserStore.generateState();
|
||||
const nonce = localUserStore.generateNonce();
|
||||
|
||||
@@ -44,8 +46,19 @@ class ConnectionManager {
|
||||
} else {
|
||||
loginUrl = `http://` + loginUrl;
|
||||
}
|
||||
|
||||
window.location.assign(loginUrl);
|
||||
|
||||
localUserStore.setAuthToken(null);
|
||||
|
||||
//TODO refactor this and don't realise previous call
|
||||
return Axios.get(loginUrl)
|
||||
.then(() => {
|
||||
window.location.assign(loginUrl);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err, "We don't have URL to regenerate authentication user");
|
||||
//TODO show modal login
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
public logout() {
|
||||
@@ -78,14 +91,14 @@ class ConnectionManager {
|
||||
this.authToken = authToken;
|
||||
|
||||
let roomPath: string;
|
||||
|
||||
|
||||
roomPath = window.location.protocol + "//" + window.location.host + START_ROOM_URL;
|
||||
|
||||
const lastRoomUrl = localUserStore.getLastRoomUrl();
|
||||
if (lastRoomUrl != undefined && lastRoomUrl != "") {
|
||||
roomPath = lastRoomUrl;
|
||||
}
|
||||
|
||||
|
||||
room = await Room.createRoom(new URL(roomPath));
|
||||
urlManager.pushRoomIdToUrl(room);
|
||||
} else if (connexionType === GameConnexionTypes.register) {
|
||||
@@ -104,11 +117,11 @@ class ConnectionManager {
|
||||
room = await Room.createRoom(
|
||||
new URL(
|
||||
window.location.protocol +
|
||||
"//" +
|
||||
window.location.host +
|
||||
roomUrl +
|
||||
window.location.search +
|
||||
window.location.hash
|
||||
"//" +
|
||||
window.location.host +
|
||||
roomUrl +
|
||||
window.location.search +
|
||||
window.location.hash
|
||||
)
|
||||
);
|
||||
urlManager.pushRoomIdToUrl(room);
|
||||
@@ -120,8 +133,8 @@ class ConnectionManager {
|
||||
this.authToken = localUserStore.getAuthToken();
|
||||
//todo: add here some kind of warning if authToken has expired.
|
||||
if (!this.authToken) {
|
||||
await this.anonymousLogin();
|
||||
// this.loadOpenIDScreen();
|
||||
await this.anonymousLogin();
|
||||
// this.loadOpenIDScreen();
|
||||
}
|
||||
this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null
|
||||
|
||||
@@ -217,9 +230,9 @@ class ConnectionManager {
|
||||
reject(
|
||||
new Error(
|
||||
"An error occurred while connecting to socket server. Retrying. Code: " +
|
||||
event.code +
|
||||
", Reason: " +
|
||||
event.reason
|
||||
event.code +
|
||||
", Reason: " +
|
||||
event.reason
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user