Set state in local storage when openid provider redirect on jwt with token value

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
Gregoire Parant 2021-11-10 18:26:50 +01:00
parent 7406b62093
commit 1db22d82af
2 changed files with 13 additions and 6 deletions

View File

@ -91,6 +91,16 @@ class ConnectionManager {
//TODO if jwt is defined, state and nonce can to be deleted
const code = urlParams.get("code");
const state = urlParams.get("state");
const jwt = urlParams.get("jwt");
if (jwt) {
this.authToken = jwt;
localUserStore.setAuthToken(jwt);
//if we use jwt we can update new state from openid provider
if (state) {
localUserStore.setState(state);
}
}
if (!state || !localUserStore.verifyState(state)) {
throw "Could not validate state!";
}
@ -98,12 +108,6 @@ class ConnectionManager {
throw "No Auth code provided";
}
localUserStore.setCode(code);
const jwt = urlParams.get("jwt");
if (jwt) {
this.authToken = jwt;
localUserStore.setAuthToken(jwt);
}
this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl()));
try {
await this.checkAuthUserConnexion();

View File

@ -171,6 +171,9 @@ class LocalUserStore {
}
return oldValue === value;
}
setState(value: string) {
localStorage.setItem(state, value);
}
getState(): string | null {
return localStorage.getItem(state);
}