Skip to content
Snippets Groups Projects
Commit 6c15485e authored by Alfredo Chissotti's avatar Alfredo Chissotti
Browse files

Delete Secured.js

parent 596280ba
No related branches found
No related tags found
No related merge requests found
'use strict';
// import Keycloak from './keycloak-js';
class Secured {
constructor() {
this.keycloak = null;
this.authenticated = false;
const body = document.getElementById('body-id');
body.onload = function() {
const keycloak = new Keycloak('http://localhost:3000/keycloak.json');
keycloak.init({
onLoad: 'login-required' // login-required will authenticate the client if the user is logged-in to Keycloak or display the login page if not.
}).then(function(authenticated) {
this.keycloak = keycloak;
this.authenticated = authenticated;
});
}
}
async getUserInfo() {
if(this.keycloak) {
const userInfo = await this.keycloak.loadUserProfile();
return {name: userInfo.name, email: userInfo.email, id: userInfo.sub};
}
return null;
}
logout() {
if(this.keycloak)
this.keycloak.logout();
}
}
export default Secured;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment