{"remainingRequest":"/var/www/html/payroll_manager/front-end/node_modules/thread-loader/dist/cjs.js??ref--4-2!/var/www/html/payroll_manager/front-end/node_modules/ts-loader/index.js??ref--4-3!/var/www/html/payroll_manager/front-end/node_modules/tslint-loader/index.js!/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/reducers/authentication.ts","dependencies":[{"path":"/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/reducers/authentication.ts","mtime":1533613271625},{"path":"/var/www/html/payroll_manager/front-end/node_modules/react-hot-loader/webpack.js","mtime":1505850161000},{"path":"/var/www/html/payroll_manager/front-end/node_modules/cache-loader/dist/cjs.js","mtime":0},{"path":"/var/www/html/payroll_manager/front-end/node_modules/thread-loader/dist/cjs.js","mtime":0},{"path":"/var/www/html/payroll_manager/front-end/node_modules/ts-loader/index.js","mtime":1530127508000},{"path":"/var/www/html/payroll_manager/front-end/node_modules/tslint-loader/index.js","mtime":1519899048000}],"contextDependencies":[],"result":["var _this = this;\nimport * as tslib_1 from \"tslib\";\nimport axios from 'axios';\nimport { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util';\nexport var ACTION_TYPES = {\n LOGIN: 'authentication/LOGIN',\n GET_SESSION: 'authentication/GET_SESSION',\n LOGOUT: 'authentication/LOGOUT',\n CLEAR_AUTH: 'authentication/CLEAR_AUTH',\n ERROR_MESSAGE: 'authentication/ERROR_MESSAGE'\n};\nvar initialState = {\n loading: false,\n isAuthenticated: false,\n loginSuccess: false,\n loginError: false,\n showModalLogin: false,\n account: {},\n errorMessage: null,\n redirectMessage: null\n};\n// Reducer\nexport default (function (state, action) {\n if (state === void 0) { state = initialState; }\n switch (action.type) {\n case REQUEST(ACTION_TYPES.LOGIN):\n case REQUEST(ACTION_TYPES.GET_SESSION):\n return tslib_1.__assign({}, state, { loading: true });\n case FAILURE(ACTION_TYPES.LOGIN):\n return tslib_1.__assign({}, initialState, { errorMessage: action.payload, showModalLogin: true, loginError: true });\n case FAILURE(ACTION_TYPES.GET_SESSION):\n return tslib_1.__assign({}, state, { loading: false, isAuthenticated: false, showModalLogin: true, errorMessage: action.payload });\n case SUCCESS(ACTION_TYPES.LOGIN):\n return tslib_1.__assign({}, state, { loading: false, loginError: false, showModalLogin: false, loginSuccess: true });\n case ACTION_TYPES.LOGOUT:\n return tslib_1.__assign({}, initialState, { showModalLogin: true });\n case SUCCESS(ACTION_TYPES.GET_SESSION): {\n var isAuthenticated = action.payload && action.payload.data && action.payload.data.activated;\n return tslib_1.__assign({}, state, { isAuthenticated: isAuthenticated, loading: false, account: action.payload.data });\n }\n case ACTION_TYPES.ERROR_MESSAGE:\n return tslib_1.__assign({}, initialState, { showModalLogin: true, redirectMessage: action.message });\n case ACTION_TYPES.CLEAR_AUTH:\n return tslib_1.__assign({}, state, { loading: false, showModalLogin: true, isAuthenticated: false });\n default:\n return state;\n }\n});\nexport var displayAuthError = function (message) { return ({ type: ACTION_TYPES.ERROR_MESSAGE, message: message }); };\nexport var getSession = function () { return function (dispatch) {\n return dispatch({\n type: ACTION_TYPES.GET_SESSION,\n payload: axios.get('api/account')\n });\n}; };\nexport var login = function (username, password, rememberMe) {\n if (rememberMe === void 0) { rememberMe = false; }\n return function (dispatch, getState) { return tslib_1.__awaiter(_this, void 0, void 0, function () {\n var data;\n return tslib_1.__generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n data = \"j_username=\" + encodeURIComponent(username) + \"&j_password=\" + encodeURIComponent(password) + \"&remember-me=\" + rememberMe + \"&submit=Login\";\n return [4 /*yield*/, dispatch({\n type: ACTION_TYPES.LOGIN,\n payload: axios.post('api/authentication', data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })\n })];\n case 1:\n _a.sent();\n dispatch(getSession());\n return [2 /*return*/];\n }\n });\n }); };\n};\nexport var logout = function () { return function (dispatch) { return tslib_1.__awaiter(_this, void 0, void 0, function () {\n return tslib_1.__generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, dispatch({\n type: ACTION_TYPES.LOGOUT,\n payload: axios.post('api/logout', {})\n })];\n case 1:\n _a.sent();\n dispatch(getSession());\n return [2 /*return*/];\n }\n });\n}); }; };\nexport var clearAuthentication = function (messageKey) { return function (dispatch, getState) {\n dispatch(displayAuthError(messageKey));\n dispatch({\n type: ACTION_TYPES.CLEAR_AUTH\n });\n}; };\n",{"version":3,"file":"/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/reducers/authentication.ts","sourceRoot":"","sources":["/var/www/html/payroll_manager/front-end/node_modules/tslint-loader/index.js!/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/reducers/authentication.ts"],"names":[],"mappings":"AAAA,iBA2HA;;AA3HA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAEjF,MAAM,CAAC,IAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EAAE,4BAA4B;IACzC,MAAM,EAAE,uBAAuB;IAC/B,UAAU,EAAE,2BAA2B;IACvC,aAAa,EAAE,8BAA8B;CAC9C,CAAC;AAEF,IAAM,YAAY,GAAG;IACnB,OAAO,EAAE,KAAK;IACd,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,KAAK;IACjB,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,EAAS;IAClB,YAAY,EAAE,IAAc;IAC5B,eAAe,EAAE,IAAc;CAChC,CAAC;AAIF,UAAU;AAEV,gBAAe,UAAC,KAAyC,EAAE,MAAM;IAAjD,sBAAA,EAAA,oBAAyC;IACvD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,KAAK,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;YACpC,4BACK,KAAK,IACR,OAAO,EAAE,IAAI,IACb;QACJ,KAAK,OAAO,CAAC,YAAY,CA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I,OAAA,UAAC,QAAQ,EAAE,QAAQ;IAClE,QAAQ,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC;QACP,IAAI,EAAE,YAAY,CAAC,UAAU;KAC9B,CAAC,CAAC;AACL,CAAC,EALgD,CAKhD,CAAC","sourcesContent":["import axios from 'axios';\n\nimport { REQUEST, SUCCESS, FAILURE } from 'app/shared/reducers/action-type.util';\n\nexport const ACTION_TYPES = {\n LOGIN: 'authentication/LOGIN',\n GET_SESSION: 'authentication/GET_SESSION',\n LOGOUT: 'authentication/LOGOUT',\n CLEAR_AUTH: 'authentication/CLEAR_AUTH',\n ERROR_MESSAGE: 'authentication/ERROR_MESSAGE'\n};\n\nconst initialState = {\n loading: false,\n isAuthenticated: false,\n loginSuccess: false,\n loginError: false, // Errors returned from server side\n showModalLogin: false,\n account: {} as any,\n errorMessage: null as string, // Errors returned from server side\n redirectMessage: null as string\n};\n\nexport type AuthenticationState = Readonly;\n\n// Reducer\n\nexport default (state: AuthenticationState = initialState, action): AuthenticationState => {\n switch (action.type) {\n case REQUEST(ACTION_TYPES.LOGIN):\n case REQUEST(ACTION_TYPES.GET_SESSION):\n return {\n ...state,\n loading: true\n };\n case FAILURE(ACTION_TYPES.LOGIN):\n return {\n ...initialState,\n errorMessage: action.payload,\n showModalLogin: true,\n loginError: true\n };\n case FAILURE(ACTION_TYPES.GET_SESSION):\n return {\n ...state,\n loading: false,\n isAuthenticated: false,\n showModalLogin: true,\n errorMessage: action.payload\n };\n case SUCCESS(ACTION_TYPES.LOGIN):\n return {\n ...state,\n loading: false,\n loginError: false,\n showModalLogin: false,\n loginSuccess: true\n };\n case ACTION_TYPES.LOGOUT:\n return {\n ...initialState,\n showModalLogin: true\n };\n case SUCCESS(ACTION_TYPES.GET_SESSION): {\n const isAuthenticated = action.payload && action.payload.data && action.payload.data.activated;\n return {\n ...state,\n isAuthenticated,\n loading: false,\n account: action.payload.data\n };\n }\n case ACTION_TYPES.ERROR_MESSAGE:\n return {\n ...initialState,\n showModalLogin: true,\n redirectMessage: action.message\n };\n case ACTION_TYPES.CLEAR_AUTH:\n return {\n ...state,\n loading: false,\n showModalLogin: true,\n isAuthenticated: false\n };\n default:\n return state;\n }\n};\n\nexport const displayAuthError = message => ({ type: ACTION_TYPES.ERROR_MESSAGE, message });\n\nexport const getSession = () => dispatch =>\n dispatch({\n type: ACTION_TYPES.GET_SESSION,\n payload: axios.get('api/account')\n });\n\nexport const login = (username, password, rememberMe = false) => async (dispatch, getState) => {\n const data = `j_username=${encodeURIComponent(username)}&j_password=${encodeURIComponent(\n password\n )}&remember-me=${rememberMe}&submit=Login`;\n await dispatch({\n type: ACTION_TYPES.LOGIN,\n payload: axios.post('api/authentication', data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })\n });\n dispatch(getSession());\n};\n\nexport const logout = () => async dispatch => {\n await dispatch({\n type: ACTION_TYPES.LOGOUT,\n payload: axios.post('api/logout', {})\n });\n dispatch(getSession());\n};\n\nexport const clearAuthentication = messageKey => (dispatch, getState) => {\n dispatch(displayAuthError(messageKey));\n dispatch({\n type: ACTION_TYPES.CLEAR_AUTH\n });\n};\n"]}]}