Skip to content

Commit

Permalink
basic authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyubinhan committed Jun 26, 2018
1 parent d82bbf4 commit f0db010
Show file tree
Hide file tree
Showing 27 changed files with 991 additions and 145 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"no-shadow": "off",
"quote-props": "off",
"max-len": "off",
"react/sort-comp": "off",
"no-unused-expressions": "warn",
"no-useless-concat": "warn",
"block-scoped-var": "error",
Expand Down
171 changes: 171 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"redux-mock-store": "^1.5.3",
"semantic-ui-react": "^0.78.2"
},
"devDependencies": {
"@types/jest": "^22.2.2",
"axios-mock-adapter": "^1.15.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"gulp": "^3.9.1",
"puppeteer": "^1.5.0",
"semantic-ui": "^2.3.1"
},
"scripts": {
Expand Down
29 changes: 27 additions & 2 deletions src/actionCreators/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
// import axios from 'axios';
import { normalize } from 'normalizr';
import { axios, saveUserProfileInLocal } from '../utils';
import * as schema from './schema';
import * as api from '../api';
import { request, success, successPagenated, error, storeAgreement, storePlan } from '../actions';
import { getAgreementsIsFetching } from '../reducers/rootReducer';
import {
request, success, successPagenated, error,
storeAgreement, storePlan, storeUser,
} from '../actions';
import { getAgreementsIsFetching, getToken } from '../reducers/rootReducer';
import * as reducerTypes from '../constants/reducerTypes';
import * as API from '../constants/API';

const createRequestHeader = state => ({
headers: {
'Authorization': `Bearer ${getToken(state)}`,
'content-type': 'application/json',
},
});

export const getUserProfile = () => (dispatch, getState) => {
return axios.get(API.GET_USER_PROFILE_ENDPOINT, createRequestHeader(getState())).then(
(response) => {
const user = response.data;
dispatch(storeUser(user));
saveUserProfileInLocal(user);
},
(err) => {
throw err;
},
);
};

export const searchAgreements = filter => (dispatch, getState) => {
if (getAgreementsIsFetching(getState(), filter)) {
Expand Down
21 changes: 21 additions & 0 deletions src/actions/authActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as actionTypes from '../constants/actionTypes';

export const storeAuthData = data => (
{
type: actionTypes.STORE_SSO_AUTH_DATA,
data,
}
);

export const storeUser = user => (
{
type: actionTypes.STORE_USER,
user,
}
);

export const signOut = () => (
{
type: actionTypes.SIGN_OUT,
}
);
1 change: 1 addition & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './storeActions';
export * from './networkActions';
export * from './authActions';
Loading

0 comments on commit f0db010

Please sign in to comment.