|
|
@@ -2,7 +2,8 @@ import { IStore } from '../app/types';
|
|
2
|
2
|
import {
|
|
3
|
3
|
CONFERENCE_FAILED,
|
|
4
|
4
|
CONFERENCE_JOINED,
|
|
5
|
|
- CONFERENCE_LEFT
|
|
|
5
|
+ CONFERENCE_LEFT,
|
|
|
6
|
+ SET_ROOM
|
|
6
|
7
|
} from '../base/conference/actionTypes';
|
|
7
|
8
|
import { CONNECTION_ESTABLISHED, CONNECTION_FAILED } from '../base/connection/actionTypes';
|
|
8
|
9
|
import { hangup } from '../base/connection/actions';
|
|
|
@@ -31,8 +32,10 @@ import {
|
|
31
|
32
|
openLoginDialog,
|
|
32
|
33
|
openWaitForOwnerDialog,
|
|
33
|
34
|
redirectToDefaultLocation,
|
|
|
35
|
+ setTokenAuthUrlSuccess,
|
|
34
|
36
|
stopWaitForOwner,
|
|
35
|
|
- waitForOwner } from './actions';
|
|
|
37
|
+ waitForOwner
|
|
|
38
|
+} from './actions';
|
|
36
|
39
|
import { LoginDialog, WaitForOwnerDialog } from './components';
|
|
37
|
40
|
import { getTokenAuthUrl, isTokenAuthEnabled } from './functions';
|
|
38
|
41
|
|
|
|
@@ -107,12 +110,25 @@ MiddlewareRegistry.register(store => next => action => {
|
|
107
|
110
|
break;
|
|
108
|
111
|
}
|
|
109
|
112
|
|
|
110
|
|
- case CONFERENCE_JOINED:
|
|
|
113
|
+ case CONFERENCE_JOINED: {
|
|
|
114
|
+ const { dispatch, getState } = store;
|
|
|
115
|
+ const state = getState();
|
|
|
116
|
+ const config = state['features/base/config'];
|
|
|
117
|
+
|
|
|
118
|
+ if (isTokenAuthEnabled(config)
|
|
|
119
|
+ && config.tokenAuthUrlAutoRedirect
|
|
|
120
|
+ && state['features/base/jwt'].jwt) {
|
|
|
121
|
+ // auto redirect is turned on and we have succesfully logged in
|
|
|
122
|
+ // let's mark that
|
|
|
123
|
+ dispatch(setTokenAuthUrlSuccess(true));
|
|
|
124
|
+ }
|
|
|
125
|
+
|
|
111
|
126
|
if (_isWaitingForOwner(store)) {
|
|
112
|
127
|
store.dispatch(stopWaitForOwner());
|
|
113
|
128
|
}
|
|
114
|
129
|
store.dispatch(hideLoginDialog());
|
|
115
|
130
|
break;
|
|
|
131
|
+ }
|
|
116
|
132
|
|
|
117
|
133
|
case CONFERENCE_LEFT:
|
|
118
|
134
|
store.dispatch(stopWaitForOwner());
|
|
|
@@ -146,14 +162,24 @@ MiddlewareRegistry.register(store => next => action => {
|
|
146
|
162
|
}
|
|
147
|
163
|
|
|
148
|
164
|
case LOGOUT: {
|
|
|
165
|
+ const { dispatch, getState } = store;
|
|
|
166
|
+ const state = getState();
|
|
|
167
|
+ const config = state['features/base/config'];
|
|
149
|
168
|
const { conference } = store.getState()['features/base/conference'];
|
|
150
|
169
|
|
|
151
|
170
|
if (!conference) {
|
|
152
|
171
|
break;
|
|
153
|
172
|
}
|
|
154
|
173
|
|
|
155
|
|
- store.dispatch(openLogoutDialog(() => {
|
|
156
|
|
- const logoutUrl = store.getState()['features/base/config'].tokenLogoutUrl;
|
|
|
174
|
+ dispatch(openLogoutDialog(() => {
|
|
|
175
|
+ const logoutUrl = config.tokenLogoutUrl;
|
|
|
176
|
+
|
|
|
177
|
+ if (isTokenAuthEnabled(config)
|
|
|
178
|
+ && config.tokenAuthUrlAutoRedirect
|
|
|
179
|
+ && state['features/base/jwt'].jwt) {
|
|
|
180
|
+ // user is logging out remove auto redirect indication
|
|
|
181
|
+ dispatch(setTokenAuthUrlSuccess(false));
|
|
|
182
|
+ }
|
|
157
|
183
|
|
|
158
|
184
|
if (logoutUrl) {
|
|
159
|
185
|
window.location.href = logoutUrl;
|
|
|
@@ -161,12 +187,31 @@ MiddlewareRegistry.register(store => next => action => {
|
|
161
|
187
|
return;
|
|
162
|
188
|
}
|
|
163
|
189
|
|
|
164
|
|
- conference.room.moderator.logout(() => store.dispatch(hangup(true)));
|
|
|
190
|
+ conference.room.moderator.logout(() => dispatch(hangup(true)));
|
|
165
|
191
|
}));
|
|
166
|
192
|
|
|
167
|
193
|
break;
|
|
168
|
194
|
}
|
|
169
|
195
|
|
|
|
196
|
+ case SET_ROOM: {
|
|
|
197
|
+ const { dispatch, getState } = store;
|
|
|
198
|
+ const state = getState();
|
|
|
199
|
+ const config = state['features/base/config'];
|
|
|
200
|
+
|
|
|
201
|
+ if (isTokenAuthEnabled(config) && config.tokenAuthUrlAutoRedirect
|
|
|
202
|
+ && state['features/authentication'].tokenAuthUrlSuccessful) {
|
|
|
203
|
+ // if we have auto redirect enabled, and we have previously logged in successfully
|
|
|
204
|
+ // let's redirect to the auth url to get the token and login again
|
|
|
205
|
+ dispatch(setTokenAuthUrlSuccess(false));
|
|
|
206
|
+
|
|
|
207
|
+ const { room } = action;
|
|
|
208
|
+
|
|
|
209
|
+ window.location.href = getTokenAuthUrl(config)(room, false);
|
|
|
210
|
+ }
|
|
|
211
|
+
|
|
|
212
|
+ break;
|
|
|
213
|
+ }
|
|
|
214
|
+
|
|
170
|
215
|
case STOP_WAIT_FOR_OWNER:
|
|
171
|
216
|
_clearExistingWaitForOwnerTimeout(store);
|
|
172
|
217
|
store.dispatch(hideDialog(WaitForOwnerDialog));
|
|
|
@@ -248,8 +293,10 @@ function _handleLogin({ dispatch, getState }: IStore) {
|
|
248
|
293
|
}
|
|
249
|
294
|
|
|
250
|
295
|
// FIXME: This method will not preserve the other URL params that were originally passed.
|
|
251
|
|
- // redirectToTokenAuthService
|
|
252
|
|
- window.location.href = getTokenAuthUrl(config)(room, false);
|
|
|
296
|
+ const tokenAuthServiceUrl = getTokenAuthUrl(config)(room, false);
|
|
|
297
|
+
|
|
|
298
|
+ // we have already shown the prejoin screen so no need to show it again(if enabled) after obtaining the token
|
|
|
299
|
+ window.location.href = `${tokenAuthServiceUrl}${tokenAuthServiceUrl.includes('#') ? '&' : '#'}skipPrejoin=true`;
|
|
253
|
300
|
} else {
|
|
254
|
301
|
dispatch(openLoginDialog());
|
|
255
|
302
|
}
|