Skip to content

Instantly share code, notes, and snippets.

@bandrzejczak
Created February 9, 2018 22:13
Show Gist options
  • Save bandrzejczak/10f0d19b408f1f16d41cec258de69d2d to your computer and use it in GitHub Desktop.
Save bandrzejczak/10f0d19b408f1f16d41cec258de69d2d to your computer and use it in GitHub Desktop.
function bootstrapAngular(keycloak, userInfo) {
angular.module('KeycloakApp')
.run(function ($rootScope) {
// store the token in header's defaults or a cookie - we'll cover that with the backend in part 2
$rootScope.currentUser = {
username: userInfo.name || userInfo.preferred_username,
roles: keycloak.realmAccess.roles
};
$rootScope.userLogout = function () {
keycloak.logout();
};
});
angular.bootstrap(document, ['KeycloakApp']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment