feat(auth): add UPGRADE_ROLE_LOGIN_OK action

This commit is contained in:
paweldomas 2017-09-22 14:06:16 -05:00 committed by Lyubo Marinov
parent 66da77bcf5
commit 9ae26a087e
4 changed files with 44 additions and 7 deletions

View File

@ -43,6 +43,17 @@ export const STOP_WAIT_FOR_OWNER = Symbol('STOP_WAIT_FOR_OWNER');
*/ */
export const UPGRADE_ROLE_FINISHED = Symbol('UPGRADE_ROLE_FINISHED'); export const UPGRADE_ROLE_FINISHED = Symbol('UPGRADE_ROLE_FINISHED');
/**
* The type of (redux) action which informs that the authentication and role
* upgrade process has finished the XMPP authentication part of the process
* (which means that the XMPP credentials are OK).
*
* {
* type: UPGRADE_ROLE_LOGIN_ON
* }
*/
export const UPGRADE_ROLE_LOGIN_OK = Symbol('UPGRADE_ROLE_LOGIN_OK');
/** /**
* The type of (redux) action which signals that the process of authenticating * The type of (redux) action which signals that the process of authenticating
* and upgrading the local participant's role has been started. * and upgrading the local participant's role has been started.

View File

@ -8,6 +8,7 @@ import {
CANCEL_WAIT_FOR_OWNER, CANCEL_WAIT_FOR_OWNER,
STOP_WAIT_FOR_OWNER, STOP_WAIT_FOR_OWNER,
UPGRADE_ROLE_FINISHED, UPGRADE_ROLE_FINISHED,
UPGRADE_ROLE_LOGIN_OK,
UPGRADE_ROLE_STARTED, UPGRADE_ROLE_STARTED,
WAIT_FOR_OWNER WAIT_FOR_OWNER
} from './actionTypes'; } from './actionTypes';
@ -38,7 +39,11 @@ export function authenticateAndUpgradeRole(
= conference.authenticateAndUpgradeRole({ = conference.authenticateAndUpgradeRole({
id, id,
password, password,
roomPassword roomPassword,
onLoginSuccessful() {
return dispatch({ type: UPGRADE_ROLE_LOGIN_OK });
}
}); });
dispatch(_upgradeRoleStarted(process)); dispatch(_upgradeRoleStarted(process));

View File

@ -66,6 +66,13 @@ class LoginDialog extends Component {
*/ */
_error: PropTypes.object, _error: PropTypes.object,
/**
* Flag indicates that during the "upgrade role and authenticate"
* process the login part was successful and the next step is to obtain
* a session ID from Jicofo.
*/
_upgradeRoleLoginOk: PropTypes.bool,
/** /**
* Redux store dispatch method. * Redux store dispatch method.
*/ */
@ -108,13 +115,16 @@ class LoginDialog extends Component {
const { const {
_connecting: connecting, _connecting: connecting,
_error: error, _error: error,
_upgradeRoleLoginOk: upgradeRoleLoginOk,
t t
} = this.props; } = this.props;
let messageKey; let messageKey;
let messageOptions; let messageOptions;
if (error) { if (upgradeRoleLoginOk) {
messageKey = 'connection.FETCH_SESSION_ID';
} else if (error) {
const { name } = error; const { name } = error;
if (name === JitsiConnectionErrors.PASSWORD_REQUIRED) { if (name === JitsiConnectionErrors.PASSWORD_REQUIRED) {
@ -243,13 +253,15 @@ class LoginDialog extends Component {
* _conference: JitsiConference, * _conference: JitsiConference,
* _configHosts: Object, * _configHosts: Object,
* _connecting: boolean, * _connecting: boolean,
* _error: Object * _error: Object,
* _upgradeRoleLoginOk: boolean
* }} * }}
*/ */
function _mapStateToProps(state) { function _mapStateToProps(state) {
const { const {
upgradeRoleError, upgradeRoleError,
upgradeRoleInProgress upgradeRoleInProgress,
upgradeRoleLoginOk
} = state['features/authentication']; } = state['features/authentication'];
const { authRequired } = state['features/base/conference']; const { authRequired } = state['features/base/conference'];
const { hosts: configHosts } = state['features/base/config']; const { hosts: configHosts } = state['features/base/config'];
@ -262,7 +274,8 @@ function _mapStateToProps(state) {
_conference: authRequired, _conference: authRequired,
_configHosts: configHosts, _configHosts: configHosts,
_connecting: Boolean(connecting) || Boolean(upgradeRoleInProgress), _connecting: Boolean(connecting) || Boolean(upgradeRoleInProgress),
_error: connectionError || upgradeRoleError _error: connectionError || upgradeRoleError,
_upgradeRoleLoginOk: upgradeRoleLoginOk
}; };
} }

View File

@ -6,6 +6,7 @@ import {
CANCEL_LOGIN, CANCEL_LOGIN,
STOP_WAIT_FOR_OWNER, STOP_WAIT_FOR_OWNER,
UPGRADE_ROLE_FINISHED, UPGRADE_ROLE_FINISHED,
UPGRADE_ROLE_LOGIN_OK,
UPGRADE_ROLE_STARTED, UPGRADE_ROLE_STARTED,
WAIT_FOR_OWNER WAIT_FOR_OWNER
} from './actionTypes'; } from './actionTypes';
@ -15,7 +16,8 @@ ReducerRegistry.register('features/authentication', (state = {}, action) => {
case CANCEL_LOGIN: case CANCEL_LOGIN:
return assign(state, { return assign(state, {
upgradeRoleError: undefined, upgradeRoleError: undefined,
upgradeRoleInProgress: undefined upgradeRoleInProgress: undefined,
upgradeRoleLoginOk: false
}); });
case STOP_WAIT_FOR_OWNER: case STOP_WAIT_FOR_OWNER:
@ -28,7 +30,13 @@ ReducerRegistry.register('features/authentication', (state = {}, action) => {
case UPGRADE_ROLE_STARTED: case UPGRADE_ROLE_STARTED:
return assign(state, { return assign(state, {
upgradeRoleError: action.error, upgradeRoleError: action.error,
upgradeRoleInProgress: action.thenableWithCancel upgradeRoleInProgress: action.thenableWithCancel,
upgradeRoleLoginOk: false
});
case UPGRADE_ROLE_LOGIN_OK:
return assign(state, {
upgradeRoleLoginOk: true
}); });
case WAIT_FOR_OWNER: case WAIT_FOR_OWNER: