Merge pull request #1562 from thecodingmachine/HotFixNewJwtTokenDecrypted
HotFix encrypted and decrypted error
This commit is contained in:
commit
832c4ab300
@ -89,27 +89,37 @@ export class Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getMapDetail(): Promise<MapDetail | RoomRedirect> {
|
private async getMapDetail(): Promise<MapDetail | RoomRedirect> {
|
||||||
const result = await Axios.get(`${PUSHER_URL}/map`, {
|
try {
|
||||||
params: {
|
const result = await Axios.get(`${PUSHER_URL}/map`, {
|
||||||
playUri: this.roomUrl.toString(),
|
params: {
|
||||||
authToken: localUserStore.getAuthToken(),
|
playUri: this.roomUrl.toString(),
|
||||||
},
|
authToken: localUserStore.getAuthToken(),
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const data = result.data;
|
const data = result.data;
|
||||||
if (data.redirectUrl) {
|
if (data.redirectUrl) {
|
||||||
return {
|
return {
|
||||||
redirectUrl: data.redirectUrl as string,
|
redirectUrl: data.redirectUrl as string,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
|
||||||
|
this._mapUrl = data.mapUrl;
|
||||||
|
this._textures = data.textures;
|
||||||
|
this._group = data.group;
|
||||||
|
this._authenticationMandatory = data.authenticationMandatory || (DISABLE_ANONYMOUS as boolean);
|
||||||
|
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
||||||
|
this._contactPage = data.contactPage || CONTACT_URL;
|
||||||
|
return new MapDetail(data.mapUrl, data.textures);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error => getMapDetail", e, e.response);
|
||||||
|
//TODO fix me and manage Error class
|
||||||
|
if (e.response?.data === "Token decrypted error") {
|
||||||
|
localUserStore.setAuthToken(null);
|
||||||
|
window.location.assign("/login");
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
|
|
||||||
this._mapUrl = data.mapUrl;
|
|
||||||
this._textures = data.textures;
|
|
||||||
this._group = data.group;
|
|
||||||
this._authenticationMandatory = data.authenticationMandatory || (DISABLE_ANONYMOUS as boolean);
|
|
||||||
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
|
||||||
this._contactPage = data.contactPage || CONTACT_URL;
|
|
||||||
return new MapDetail(data.mapUrl, data.textures);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,10 +80,17 @@ export class MapController extends BaseController {
|
|||||||
authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string);
|
authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string);
|
||||||
userId = authTokenData.identifier;
|
userId = authTokenData.identifier;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Decode token, in this case we don't need to create new token.
|
try {
|
||||||
authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string, true);
|
// Decode token, in this case we don't need to create new token.
|
||||||
userId = authTokenData.identifier;
|
authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string, true);
|
||||||
console.info("JWT expire, but decoded", userId);
|
userId = authTokenData.identifier;
|
||||||
|
console.info("JWT expire, but decoded", userId);
|
||||||
|
} catch (e) {
|
||||||
|
// The token was not good, redirect user on login page
|
||||||
|
res.writeStatus("500");
|
||||||
|
res.end("Token decrypted error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const mapDetails = await adminApi.fetchMapDetails(query.playUri as string, userId);
|
const mapDetails = await adminApi.fetchMapDetails(query.playUri as string, userId);
|
||||||
|
Loading…
Reference in New Issue
Block a user