Properly handle login/logout.
This commit is contained in:
+26
-11
@@ -317,34 +317,49 @@ export default class RoomClient
|
||||
{
|
||||
const url = `/auth/login?id=${this._peerId}`;
|
||||
|
||||
this._loginWindow = window.open(url, 'loginWindow');
|
||||
window.open(url, 'loginWindow');
|
||||
}
|
||||
|
||||
logout()
|
||||
{
|
||||
window.location = '/auth/logout';
|
||||
window.open('/auth/logout', 'logoutWindow');
|
||||
}
|
||||
|
||||
receiveFromChildWindow(data)
|
||||
receiveLoginChildWindow(data)
|
||||
{
|
||||
logger.debug('receiveFromChildWindow() | [data:"%o"]', data);
|
||||
|
||||
const { displayName, picture } = data;
|
||||
|
||||
store.dispatch(stateActions.setDisplayName(displayName));
|
||||
store.dispatch(stateActions.setPicture(picture));
|
||||
store.dispatch(stateActions.loggedIn());
|
||||
if (store.getState().room.state === 'connected')
|
||||
{
|
||||
this.changeDisplayName(displayName);
|
||||
this.changePicture(picture);
|
||||
}
|
||||
else
|
||||
{
|
||||
store.dispatch(stateActions.setDisplayName(displayName));
|
||||
store.dispatch(stateActions.setPicture(picture));
|
||||
}
|
||||
|
||||
store.dispatch(stateActions.loggedIn(true));
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
text : 'You are logged in.'
|
||||
}));
|
||||
}
|
||||
|
||||
if (store.getState().room.state !== 'new') // no socket yet
|
||||
{
|
||||
this.changeDisplayName(displayName);
|
||||
this.changePicture(picture);
|
||||
}
|
||||
receiveLogoutChildWindow()
|
||||
{
|
||||
logger.debug('receiveLogoutChildWindow()');
|
||||
|
||||
store.dispatch(stateActions.loggedIn(false));
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
text : 'You are logged out.'
|
||||
}));
|
||||
}
|
||||
|
||||
_soundNotification()
|
||||
|
||||
@@ -165,6 +165,14 @@ export const setDisplayName = (displayName) =>
|
||||
};
|
||||
};
|
||||
|
||||
export const setDisplayNameInProgress = (flag) =>
|
||||
{
|
||||
return {
|
||||
type : 'SET_DISPLAY_NAME_IN_PROGRESS',
|
||||
payload : { flag }
|
||||
};
|
||||
};
|
||||
|
||||
export const toggleAdvancedMode = () =>
|
||||
{
|
||||
return {
|
||||
@@ -641,9 +649,10 @@ export const setPeerPicture = (peerId, picture) =>
|
||||
payload : { peerId, picture }
|
||||
});
|
||||
|
||||
export const loggedIn = () =>
|
||||
export const loggedIn = (flag) =>
|
||||
({
|
||||
type : 'LOGGED_IN'
|
||||
type : 'LOGGED_IN',
|
||||
payload : { flag }
|
||||
});
|
||||
|
||||
export const toggleJoined = () =>
|
||||
|
||||
+13
-1
@@ -12,6 +12,7 @@ const initialState =
|
||||
webcamInProgress : false,
|
||||
audioInProgress : false,
|
||||
screenShareInProgress : false,
|
||||
displayNameInProgress : false,
|
||||
loginEnabled : false,
|
||||
raiseHand : false,
|
||||
raiseHandInProgress : false,
|
||||
@@ -39,7 +40,11 @@ const me = (state = initialState, action) =>
|
||||
}
|
||||
|
||||
case 'LOGGED_IN':
|
||||
return { ...state, loggedIn: true };
|
||||
{
|
||||
const { flag } = action.payload;
|
||||
|
||||
return { ...state, loggedIn: flag };
|
||||
}
|
||||
|
||||
case 'USER_LOGOUT':
|
||||
return { ...state, loggedIn: false };
|
||||
@@ -114,6 +119,13 @@ const me = (state = initialState, action) =>
|
||||
return { ...state, raiseHandInProgress: flag };
|
||||
}
|
||||
|
||||
case 'SET_DISPLAY_NAME_IN_PROGRESS':
|
||||
{
|
||||
const { flag } = action.payload;
|
||||
|
||||
return { ...state, displayNameInProgress: flag };
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user