Fix the display the error message if ssoLogin action fails (#4609)

* Fix the display the error message if ssoLogin action fails

* Fix typo

* Remove token parameter
This commit is contained in:
Elias Nahum 2020-07-23 16:42:43 -04:00 committed by GitHub
parent ac2a3a143a
commit baca7bcf87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

View file

@ -40,8 +40,8 @@ export function completeLogin(user, deviceToken) {
}
// Data retention
if (config.DataRetentionEnableMessageDeletion && config.DataRetentionEnableMessageDeletion === 'true' &&
license.IsLicensed === 'true' && license.DataRetention === 'true') {
if (config?.DataRetentionEnableMessageDeletion && config?.DataRetentionEnableMessageDeletion === 'true' &&
license?.IsLicensed === 'true' && license?.DataRetention === 'true') {
dispatch(getDataRetentionPolicy());
} else {
dispatch({type: GeneralTypes.RECEIVED_DATA_RETENTION_POLICY, data: {}});
@ -183,14 +183,10 @@ export function login(loginId, password, mfaToken, ldapOnly = false) {
};
}
export function ssoLogin(token) {
export function ssoLogin() {
return async (dispatch, getState) => {
const state = getState();
const deviceToken = state.entities?.general?.deviceToken;
Client4.setToken(token);
await setCSRFFromCookie(Client4.getUrl());
const result = await dispatch(loadMe());
if (!result.error) {

View file

@ -41,6 +41,8 @@ const handleRedirectProtocol = (url, response) => {
};
Client4.doFetchWithResponse = async (url, options) => {
// eslint-disable-next-line no-console
console.log('Request endpoint', url);
const customHeaders = LocalConfig.CustomRequestHeaders;
let waitsForConnectivity = false;
let timeoutIntervalForResource = 30;
@ -136,7 +138,7 @@ Client4.doFetchWithResponse = async (url, options) => {
}
throw new ClientError(Client4.getUrl(), {
message: msg,
message: `${msg} url = ${url}`,
server_error_id: data.id,
status_code: data.status_code,
url,

View file

@ -119,7 +119,13 @@ class SSO extends PureComponent {
CookieManager.get(parsedUrl.href, true).then((res) => {
const mmtoken = res.MMAUTHTOKEN;
const csrf = res.MMCSRF;
const token = typeof mmtoken === 'object' ? mmtoken.value : mmtoken;
const csrfToken = typeof csrf === 'object' ? csrf.value : csrf;
if (csrfToken) {
Client4.setCSRF(csrfToken);
}
if (token) {
clearTimeout(this.cookiesTimeout);
@ -129,7 +135,7 @@ class SSO extends PureComponent {
} = this.props.actions;
Client4.setToken(token);
ssoLogin(token).then((result) => {
ssoLogin().then((result) => {
if (result.error) {
this.onLoadEndError(result.error);
return;
@ -227,15 +233,13 @@ class SSO extends PureComponent {
const style = getStyleSheet(theme);
let content;
if (!renderWebView) {
content = this.renderLoading();
} else if (error) {
if (error) {
content = (
<View style={style.errorContainer}>
<Text style={style.errorText}>{error}</Text>
</View>
);
} else {
} else if (renderWebView) {
content = (
<WebView
ref={this.webViewRef}
@ -252,6 +256,8 @@ class SSO extends PureComponent {
cacheEnabled={false}
/>
);
} else {
content = this.renderLoading();
}
return (