* Revert updated dependecies for SSO * Fix test setup Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
24 lines
768 B
JavaScript
24 lines
768 B
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Client4} from '@mm-redux/client';
|
|
import CookieManager from 'react-native-cookies';
|
|
|
|
export function setCSRFFromCookie(url) {
|
|
return new Promise((resolve) => {
|
|
CookieManager.get(url, false).then((cookies) => {
|
|
const token = cookies.MMCSRF;
|
|
if (token) {
|
|
let value = null;
|
|
if (typeof token === 'object' && Object.prototype.hasOwnProperty.call(token, 'value')) {
|
|
value = token.value;
|
|
} else {
|
|
value = token;
|
|
}
|
|
|
|
Client4.setCSRF(value);
|
|
}
|
|
resolve();
|
|
});
|
|
});
|
|
}
|