Skip to content

Commit

Permalink
♻️ Refactor Auth0 callback function to provide user profile data
Browse files Browse the repository at this point in the history
  • Loading branch information
XuTheBunny committed Mar 18, 2019
1 parent 55c7eff commit 864bc2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Auth.js
Expand Up @@ -29,7 +29,7 @@ export default class Auth {
this.auth0.parseHash((err, authResult) => {
if (authResult && authResult.accessToken && authResult.idToken) {
this.setSession(authResult);
callback(authResult.accessToken);
callback(authResult.accessToken, authResult.idToken);
props.history.push('/');
} else if (err) {
console.log(err);
Expand Down
4 changes: 2 additions & 2 deletions src/actions/auth.js
Expand Up @@ -64,7 +64,7 @@ export function loginUser(id_token) {
};
}

export function auth0Login(id_token) {
export function auth0Login(access_token, id_token) {
return dispatch => {
dispatch(beginAuth(true));
const jwtData = jwtDecode(id_token);
Expand All @@ -78,6 +78,6 @@ export function auth0Login(id_token) {
roles: jwtData['https://kidsfirstdrc.org/roles'],
permissions: jwtData['https://kidsfirstdrc.org/permissions']
};
dispatch(authSuccess(id_token, jwtData.exp, user));
dispatch(authSuccess(access_token, jwtData.exp, user));
};
}
3 changes: 2 additions & 1 deletion src/views/Callback.js
Expand Up @@ -14,7 +14,8 @@ class Callback extends Component {

function mapDispatchToProps(dispatch) {
return {
auth0Login: id_token => dispatch(auth0Login(id_token))
auth0Login: (access_token, id_token) =>
dispatch(auth0Login(access_token, id_token))
};
}

Expand Down

0 comments on commit 864bc2f

Please sign in to comment.