Merge pull request #1562 from thecodingmachine/HotFixNewJwtTokenDecrypted

HotFix encrypted and decrypted error
This commit is contained in:
grégoire parant 2021-11-16 11:26:35 +01:00 committed by GitHub
commit 832c4ab300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 23 deletions

View File

@ -89,6 +89,7 @@ export class Room {
}
private async getMapDetail(): Promise<MapDetail | RoomRedirect> {
try {
const result = await Axios.get(`${PUSHER_URL}/map`, {
params: {
playUri: this.roomUrl.toString(),
@ -110,6 +111,15 @@ export class Room {
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;
}
}
/**

View File

@ -80,10 +80,17 @@ export class MapController extends BaseController {
authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string);
userId = authTokenData.identifier;
} catch (e) {
try {
// Decode token, in this case we don't need to create new token.
authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string, true);
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);