Skip to content

Commit 6179ba6

Browse files
committed
squash: Replace resuming event with CONNECTION_TOKEN_EXPIRED one.
1 parent 91ea707 commit 6179ba6

File tree

4 files changed

+53
-40
lines changed

4 files changed

+53
-40
lines changed

lang/main.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
"lockTitle": "Lock failed",
385385
"login": "Login",
386386
"loginFailed": "Login failed.",
387-
"loginOnResume": "Your authentication session is about to expire. You need to login again to continue the meeting.",
387+
"loginOnResume": "Your authentication session has expired. You need to login again to continue the meeting.",
388388
"loginQuestion": "Are you sure you want to login and leave the conference?",
389389
"logoutQuestion": "Are you sure you want to logout and leave the conference?",
390390
"logoutTitle": "Logout",

react/features/base/connection/actionTypes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ export const CONNECTION_PROPERTIES_UPDATED = 'CONNECTION_PROPERTIES_UPDATED';
5252
export const CONNECTION_WILL_CONNECT = 'CONNECTION_WILL_CONNECT';
5353

5454
/**
55-
* The type of (redux) action which signals that a connection will try to resume.
55+
* The type of (redux) action which signals that the token for a connection is expired.
5656
*
5757
* {
58-
* type: CONNECTION_RESUMING,
58+
* type: CONNECTION_TOKEN_EXPIRED,
5959
* connection: JitsiConnection
6060
* }
6161
*/
62-
export const CONNECTION_RESUMING = 'CONNECTION_RESUMING';
62+
export const CONNECTION_TOKEN_EXPIRED = 'CONNECTION_TOKEN_EXPIRED';
6363

6464
/**
6565
* The type of (redux) action which sets the location URL of the application,

react/features/base/connection/actions.any.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
CONNECTION_ESTABLISHED,
1919
CONNECTION_FAILED,
2020
CONNECTION_PROPERTIES_UPDATED,
21-
CONNECTION_RESUMING,
21+
CONNECTION_TOKEN_EXPIRED,
2222
CONNECTION_WILL_CONNECT,
2323
SET_LOCATION_URL,
2424
SET_PREFER_VISITOR
@@ -242,8 +242,8 @@ export function _connectInternal(id?: string, password?: string) {
242242
JitsiConnectionEvents.PROPERTIES_UPDATED,
243243
_onPropertiesUpdate);
244244
connection.addEventListener(
245-
JitsiConnectionEvents.CONNECTION_RESUMING,
246-
_onConnectionResume);
245+
JitsiConnectionEvents.CONNECTION_TOKEN_EXPIRED,
246+
_onTokenExpired);
247247

248248
/**
249249
* Unsubscribe the connection instance from
@@ -334,13 +334,8 @@ export function _connectInternal(id?: string, password?: string) {
334334
* @private
335335
* @returns {void}
336336
*/
337-
function _onConnectionResume(): void {
338-
// when inline, we cancel resume as we will get a new token and refresh it by resuming
339-
if (isTokenAuthInline(getState()['features/base/config']) && getState()['features/base/jwt'].jwt) {
340-
connection.cancelResume();
341-
}
342-
343-
dispatch(_connectionResuming(connection));
337+
function _onTokenExpired(): void {
338+
dispatch(_connectionTokenExpired(connection));
344339
}
345340

346341
/**
@@ -385,18 +380,18 @@ function _connectionWillConnect(connection: Object) {
385380
}
386381

387382
/**
388-
* Create an action for when a connection will resume.
383+
* Create an action for when a connection token is expired.
389384
*
390-
* @param {JitsiConnection} connection - The {@code JitsiConnection} which will resume.
385+
* @param {JitsiConnection} connection - The {@code JitsiConnection} token is expired.
391386
* @private
392387
* @returns {{
393-
* type: CONNECTION_RESUMING,
388+
* type: CONNECTION_TOKEN_EXPIRED,
394389
* connection: JitsiConnection
395390
* }}
396391
*/
397-
function _connectionResuming(connection: Object) {
392+
function _connectionTokenExpired(connection: Object) {
398393
return {
399-
type: CONNECTION_RESUMING,
394+
type: CONNECTION_TOKEN_EXPIRED,
400395
connection
401396
};
402397
}

react/features/base/jwt/middleware.ts

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import { AnyAction } from 'redux';
44

55
import { IStore } from '../../app/types';
66
import { loginWithPopup } from '../../authentication/actions';
7+
import LoginQuestionDialog from '../../authentication/components/web/LoginQuestionDialog';
78
import { getTokenAuthUrl, isTokenAuthInline } from '../../authentication/functions';
89
import { isVpaasMeeting } from '../../jaas/functions';
910
import { hideNotification, showNotification } from '../../notifications/actions';
1011
import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../../notifications/constants';
1112
import { authStatusChanged } from '../conference/actions.any';
1213
import { getCurrentConference } from '../conference/functions';
1314
import { SET_CONFIG } from '../config/actionTypes';
14-
import { CONNECTION_ESTABLISHED, CONNECTION_RESUMING, SET_LOCATION_URL } from '../connection/actionTypes';
15+
import { CONNECTION_ESTABLISHED, CONNECTION_TOKEN_EXPIRED, SET_LOCATION_URL } from '../connection/actionTypes';
16+
import { openDialog } from '../dialog/actions';
17+
import { browser } from '../lib-jitsi-meet';
1518
import { participantUpdated } from '../participants/actions';
1619
import { getLocalParticipant } from '../participants/functions';
1720
import { IParticipant } from '../participants/types';
@@ -55,12 +58,11 @@ MiddlewareRegistry.register(store => next => action => {
5558
// XXX The JSON Web Token (JWT) is not the only piece of state that we
5659
// have decided to store in the feature jwt
5760
return _setConfigOrLocationURL(store, next, action);
58-
case CONNECTION_RESUMING: {
61+
case CONNECTION_TOKEN_EXPIRED: {
5962
const jwt = state['features/base/jwt'].jwt;
6063
const refreshToken = state['features/base/jwt'].refreshToken;
6164

62-
if (typeof APP !== 'undefined'
63-
&& jwt && isTokenAuthInline(state['features/base/config'])
65+
if (typeof APP !== 'undefined' && jwt
6466
&& validateJwt(jwt).find((e: any) => e.key === JWT_VALIDATION_ERRORS.TOKEN_EXPIRED)) {
6567
const { connection, locationURL = { href: '' } as URL } = state['features/base/connection'];
6668
const { tenant } = parseURIString(locationURL.href) || {};
@@ -92,23 +94,39 @@ MiddlewareRegistry.register(store => next => action => {
9294
customActionHandler: [ () => {
9395
store.dispatch(hideNotification(PROMPT_LOGIN_NOTIFICATION_ID));
9496

95-
// Use refresh token if available, otherwise fall back to silent login
96-
loginWithPopup(url)
97-
.then((result: { accessToken: string; idToken: string; refreshToken?: string; }) => {
98-
// @ts-ignore
99-
const token: string = result.accessToken;
100-
const idToken: string = result.idToken;
101-
const newRefreshToken: string | undefined = result.refreshToken;
102-
103-
// @ts-ignore
104-
dispatch(setJWT(token, idToken, newRefreshToken || refreshToken));
105-
106-
connection?.refreshToken(token)
107-
.catch((err: any) => {
108-
dispatch(setJWT());
109-
logger.error(err);
110-
});
111-
}).catch(logger.error);
97+
if (isTokenAuthInline(state['features/base/config'])) {
98+
// Use refresh token if available, otherwise fall back to silent login
99+
loginWithPopup(url)
100+
.then((result: { accessToken: string; idToken: string; refreshToken?: string; }) => {
101+
// @ts-ignore
102+
const token: string = result.accessToken;
103+
const idToken: string = result.idToken;
104+
const newRefreshToken: string | undefined = result.refreshToken;
105+
106+
// @ts-ignore
107+
dispatch(setJWT(token, idToken, newRefreshToken || refreshToken));
108+
109+
connection?.refreshToken(token)
110+
.catch((err: any) => {
111+
dispatch(setJWT());
112+
logger.error(err);
113+
});
114+
}).catch(logger.error);
115+
} else {
116+
dispatch(openDialog('LoginQuestionDialog', LoginQuestionDialog, {
117+
handler: () => {
118+
// Give time for the dialog to close.
119+
setTimeout(() => {
120+
if (browser.isElectron()) {
121+
window.open(url, '_blank');
122+
} else {
123+
window.location.href = url;
124+
}
125+
}, 500);
126+
}
127+
}));
128+
}
129+
112130
} ],
113131
appearance: NOTIFICATION_TYPE.ERROR
114132
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));

0 commit comments

Comments
 (0)