mattermost-mobile/app/actions/views/select_server.js
enahum c13a436d18 Enable SAML authentication (#325)
* enable saml authentication

* Fix unit tests

* Fix android cookies

* Feedback review
2017-03-09 14:07:18 -03:00

38 lines
1 KiB
JavaScript

// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {ViewTypes} from 'app/constants';
import {goToLogin, goToLoginOptions} from 'app/actions/navigation';
export function handleServerUrlChanged(serverUrl) {
return async (dispatch, getState) => {
dispatch({
type: ViewTypes.SERVER_URL_CHANGED,
serverUrl
}, getState);
};
}
export function handleLoginOptions() {
return async (dispatch, getState) => {
const {config, license} = getState().entities.general;
const samlEnabled = config.EnableSaml === 'true' && license.IsLicensed === 'true' && license.SAML === 'true';
let options = 0;
if (samlEnabled) {
options += 1;
}
if (options) {
await goToLoginOptions()(dispatch, getState);
} else {
await goToLogin()(dispatch, getState);
}
};
}
export default {
handleServerUrlChanged,
handleLoginOptions
};