Skip to content

Commit

Permalink
Allow applications to get user information from JWT (#48)
Browse files Browse the repository at this point in the history
* Allow applications to get user information from JWT

* Wrap getUser info as promise which can be resolved after login happens
  • Loading branch information
karelhala committed Oct 16, 2018
1 parent f915e50 commit 1776ac9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function initCallback() {

export default () => {
jwt.onInit(initCallback);
jwt.init({
return jwt.init({
keycloakOptions: { clientId: 'customer-portal' },
keycloakInitOptions: { responseMode: 'query' }
});
Expand Down
4 changes: 3 additions & 1 deletion src/js/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { spinUpStore } from './redux-config';
import * as actionTypes from './redux/action-types';
import loadInventory from './inventory';
import auth from './auth';
import jwt from 'jwt-redhat';

auth();
const onAuth = auth();

// used for translating event names exposed publicly to internal event names
const PUBLIC_EVENTS = {
Expand Down Expand Up @@ -31,6 +32,7 @@ window.insights.chrome = {
return middlewareListener.addNew(PUBLIC_EVENTS[type](callback));
};

window.insights.chrome.getUser = () => onAuth.then(jwt.getUserInfo);
window.insights.chrome.$internal = { store };
}
};
Expand Down

0 comments on commit 1776ac9

Please sign in to comment.