Properly handle login/logout.
parent
d3d3e9626e
commit
98caed6e4a
|
|
@ -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 = () =>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function httpHelper(data)
|
||||
exports.loginHelper = function(data)
|
||||
{
|
||||
const html = `<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
@ -10,7 +10,7 @@ function httpHelper(data)
|
|||
<script type='text/javascript'>
|
||||
let data = ${JSON.stringify(data)};
|
||||
|
||||
window.opener.CLIENT.receiveFromChildWindow(data);
|
||||
window.opener.CLIENT.receiveLoginChildWindow(data);
|
||||
|
||||
window.close();
|
||||
</script>
|
||||
|
|
@ -18,6 +18,24 @@ function httpHelper(data)
|
|||
</html>`;
|
||||
|
||||
return html;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = httpHelper;
|
||||
exports.logoutHelper = function()
|
||||
{
|
||||
const html = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Multiparty Meeting</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type='text/javascript'>
|
||||
window.opener.CLIENT.receiveLogoutChildWindow();
|
||||
|
||||
window.close();
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
return html;
|
||||
};
|
||||
|
|
@ -6,7 +6,6 @@ const config = require('./config/config');
|
|||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
const spdy = require('spdy');
|
||||
const { constants } = require('crypto');
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const cookieParser = require('cookie-parser');
|
||||
|
|
@ -18,7 +17,10 @@ const Room = require('./lib/Room');
|
|||
const Peer = require('./lib/Peer');
|
||||
const base64 = require('base-64');
|
||||
const helmet = require('helmet');
|
||||
const httpHelper = require('./httpHelper');
|
||||
const {
|
||||
loginHelper,
|
||||
logoutHelper
|
||||
} = require('./httpHelper');
|
||||
// auth
|
||||
const passport = require('passport');
|
||||
const redis = require('redis');
|
||||
|
|
@ -88,7 +90,8 @@ const session = expressSession({
|
|||
store : new RedisStore({ client }),
|
||||
cookie : {
|
||||
secure : true,
|
||||
httpOnly : true
|
||||
httpOnly : true,
|
||||
maxAge : 60 * 60 * 1000 // Expire after 1 hour since last request from user
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -268,7 +271,7 @@ async function setupAuth(oidcIssuer)
|
|||
app.get('/auth/logout', (req, res) =>
|
||||
{
|
||||
req.logout();
|
||||
res.redirect('/');
|
||||
res.send(logoutHelper());
|
||||
});
|
||||
|
||||
// callback
|
||||
|
|
@ -301,7 +304,7 @@ async function setupAuth(oidcIssuer)
|
|||
peer && (peer.displayName = displayName);
|
||||
peer && (peer.picture = picture);
|
||||
|
||||
res.send(httpHelper({
|
||||
res.send(loginHelper({
|
||||
displayName,
|
||||
picture
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue