Allow API auth with app or user token

stable/1.0.x
Alex Gleason 2020-04-29 14:06:26 -05:00
rodzic eef41485c1
commit 238eed4c1a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -25,13 +25,15 @@ function setCSRFHeader() {
ready(setCSRFHeader);
export default getState => {
const user_token = getState().getIn(['auth', 'user', 'access_token']);
const app_token = getState().getIn(['auth', 'app', 'access_token']);
const access_token = user_token || app_token;
const getToken = (getState, authType) =>
getState().getIn(['auth', authType, 'access_token']);
export default (getState, authType = 'user') => {
const accessToken = getToken(getState, authType);
return axios.create({
headers: Object.assign(csrfHeader, access_token ? {
'Authorization': `Bearer ${access_token}`,
headers: Object.assign(csrfHeader, accessToken ? {
'Authorization': `Bearer ${accessToken}`,
} : {}),
transformResponse: [function(data) {