apax-react-core
Advanced tools
Comparing version 0.4.0 to 0.5.0
import axios from 'axios'; | ||
import { call, select, all, put, take } from 'redux-saga/effects'; | ||
import Cookies from 'universal-cookie'; | ||
import Cookies$1 from 'universal-cookie'; | ||
@@ -192,3 +192,3 @@ var SET_USER_TOKEN = 'SET_USER_TOKEN'; | ||
var env = (function () { | ||
var env$1 = (function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState$1; | ||
@@ -203,3 +203,4 @@ var action = arguments[1]; | ||
api_root: action.api_root, | ||
token_name: action.token_name | ||
token_name: action.token_name, | ||
token_type: action.token_type | ||
}); | ||
@@ -219,5 +220,17 @@ | ||
var account = _ref2.account; | ||
return account ? account.token : null; | ||
if (!!account.token) { | ||
return account.token; | ||
} else if (!!env.token_name) { | ||
return new Cookies().get(env.token_name); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
var getTokenType = function getTokenType(_ref3) { | ||
var account = _ref3.account; | ||
return account ? account.token_type : 'Token'; | ||
}; | ||
var getApiRoot = function getApiRoot(_ref) { | ||
@@ -241,3 +254,3 @@ var env = _ref.env; | ||
function getHeaders(authenticationRequired) { | ||
var headers, token; | ||
var headers, token, token_type; | ||
return regeneratorRuntime.wrap(function getHeaders$(_context) { | ||
@@ -252,3 +265,3 @@ while (1) { | ||
if (!authenticationRequired) { | ||
_context.next = 6; | ||
_context.next = 9; | ||
break; | ||
@@ -262,12 +275,17 @@ } | ||
token = _context.sent; | ||
_context.next = 7; | ||
return select(getTokenType); | ||
case 7: | ||
token_type = _context.sent; | ||
if (token) { | ||
headers.Authorization = 'Token ' + token; | ||
headers.Authorization = token_type + ' ' + token; | ||
} | ||
case 6: | ||
case 9: | ||
return _context.abrupt('return', { headers: headers }); | ||
case 7: | ||
case 10: | ||
case 'end': | ||
@@ -536,3 +554,3 @@ return _context.stop(); | ||
new Cookies().set(tokenName, response.key, { path: '/' }); | ||
new Cookies$1().set(tokenName, response.key, { path: '/' }); | ||
@@ -583,3 +601,3 @@ _context.next = 12; | ||
new Cookies().set(tokenName, response.key, { path: '/' }); | ||
new Cookies$1().set(tokenName, response.key, { path: '/' }); | ||
@@ -649,3 +667,3 @@ _context2.next = 12; | ||
new Cookies().remove(tokenName, { path: '/' }); | ||
new Cookies$1().remove(tokenName, { path: '/' }); | ||
@@ -677,3 +695,3 @@ _context3.next = 21; | ||
tokenName = _context4.sent; | ||
token = new Cookies().get(tokenName); | ||
token = new Cookies$1().get(tokenName); | ||
@@ -740,3 +758,3 @@ if (!token) { | ||
new Cookies().remove(_tokenName, { path: '/' }); | ||
new Cookies$1().remove(_tokenName, { path: '/' }); | ||
@@ -771,3 +789,3 @@ case 30: | ||
export { account as accountReducer, env as envReducer, _callee as accountSagas, api, apiPost, apiGet, apiPut, apiPatch, apiDelete, getUser, getToken, getApiRoot, getTokenName, SET_USER_TOKEN, LOAD_USER, LOAD_USER_SUCCESS, LOAD_USER_ERROR, LOGIN, SIGNUP, LOGIN_SUCCESS, SIGNUP_SUCCESS, SIGNUP_ERROR, LOGIN_ERROR, LOGOUT, CLEAR_ERRORS, setUserToken, login, logout, signup, SET_ENV, setEnv }; | ||
export { account as accountReducer, env$1 as envReducer, _callee as accountSagas, api, apiPost, apiGet, apiPut, apiPatch, apiDelete, getUser, getToken, getTokenType, getApiRoot, getTokenName, SET_USER_TOKEN, LOAD_USER, LOAD_USER_SUCCESS, LOAD_USER_ERROR, LOGIN, SIGNUP, LOGIN_SUCCESS, SIGNUP_SUCCESS, SIGNUP_ERROR, LOGIN_ERROR, LOGOUT, CLEAR_ERRORS, setUserToken, login, logout, signup, SET_ENV, setEnv }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var effects = require('redux-saga/effects'); | ||
var Cookies = _interopDefault(require('universal-cookie')); | ||
var Cookies$1 = _interopDefault(require('universal-cookie')); | ||
@@ -199,3 +199,3 @@ var SET_USER_TOKEN = 'SET_USER_TOKEN'; | ||
var env = (function () { | ||
var env$1 = (function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState$1; | ||
@@ -210,3 +210,4 @@ var action = arguments[1]; | ||
api_root: action.api_root, | ||
token_name: action.token_name | ||
token_name: action.token_name, | ||
token_type: action.token_type | ||
}); | ||
@@ -226,5 +227,17 @@ | ||
var account = _ref2.account; | ||
return account ? account.token : null; | ||
if (!!account.token) { | ||
return account.token; | ||
} else if (!!env.token_name) { | ||
return new Cookies().get(env.token_name); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
var getTokenType = function getTokenType(_ref3) { | ||
var account = _ref3.account; | ||
return account ? account.token_type : 'Token'; | ||
}; | ||
var getApiRoot = function getApiRoot(_ref) { | ||
@@ -248,3 +261,3 @@ var env = _ref.env; | ||
function getHeaders(authenticationRequired) { | ||
var headers, token; | ||
var headers, token, token_type; | ||
return regeneratorRuntime.wrap(function getHeaders$(_context) { | ||
@@ -259,3 +272,3 @@ while (1) { | ||
if (!authenticationRequired) { | ||
_context.next = 6; | ||
_context.next = 9; | ||
break; | ||
@@ -269,12 +282,17 @@ } | ||
token = _context.sent; | ||
_context.next = 7; | ||
return effects.select(getTokenType); | ||
case 7: | ||
token_type = _context.sent; | ||
if (token) { | ||
headers.Authorization = 'Token ' + token; | ||
headers.Authorization = token_type + ' ' + token; | ||
} | ||
case 6: | ||
case 9: | ||
return _context.abrupt('return', { headers: headers }); | ||
case 7: | ||
case 10: | ||
case 'end': | ||
@@ -543,3 +561,3 @@ return _context.stop(); | ||
new Cookies().set(tokenName, response.key, { path: '/' }); | ||
new Cookies$1().set(tokenName, response.key, { path: '/' }); | ||
@@ -590,3 +608,3 @@ _context.next = 12; | ||
new Cookies().set(tokenName, response.key, { path: '/' }); | ||
new Cookies$1().set(tokenName, response.key, { path: '/' }); | ||
@@ -656,3 +674,3 @@ _context2.next = 12; | ||
new Cookies().remove(tokenName, { path: '/' }); | ||
new Cookies$1().remove(tokenName, { path: '/' }); | ||
@@ -684,3 +702,3 @@ _context3.next = 21; | ||
tokenName = _context4.sent; | ||
token = new Cookies().get(tokenName); | ||
token = new Cookies$1().get(tokenName); | ||
@@ -747,3 +765,3 @@ if (!token) { | ||
new Cookies().remove(_tokenName, { path: '/' }); | ||
new Cookies$1().remove(_tokenName, { path: '/' }); | ||
@@ -779,3 +797,3 @@ case 30: | ||
exports.accountReducer = account; | ||
exports.envReducer = env; | ||
exports.envReducer = env$1; | ||
exports.accountSagas = _callee; | ||
@@ -790,2 +808,3 @@ exports.api = api; | ||
exports.getToken = getToken; | ||
exports.getTokenType = getTokenType; | ||
exports.getApiRoot = getApiRoot; | ||
@@ -792,0 +811,0 @@ exports.getTokenName = getTokenName; |
{ | ||
"name": "apax-react-core", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Contains core react functionality developed by Apax Software LLC", | ||
@@ -5,0 +5,0 @@ "author": "apaxsoftware", |
@@ -11,2 +11,20 @@ # apax-react-core | ||
### Connecting Locally | ||
To connect to this repository locally, go to the root directory for apax-react-core: | ||
``` | ||
yarn link | ||
``` | ||
Then go to the project you want to connect (at the root level) and enter: | ||
``` | ||
yarn link apax-react-core | ||
``` | ||
To separate the projects again: | ||
``` | ||
yarn unlink | ||
``` | ||
inside apax-react-core level terminal. | ||
### Initialize Environment | ||
@@ -13,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83707
1327
208