From e82e62da23ecd4477495057df852649992815aeb Mon Sep 17 00:00:00 2001 From: mattyl006 Date: Wed, 5 Oct 2022 17:28:07 +0200 Subject: [PATCH] real keycloak instance --- src/App.js | 5 +++++ src/api/loginTest.js | 18 ------------------ src/services/KeyCloakService.js | 10 ++++++---- 3 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 src/api/loginTest.js diff --git a/src/App.js b/src/App.js index 8bccc50..7e450ec 100644 --- a/src/App.js +++ b/src/App.js @@ -18,6 +18,11 @@ import LoggedBar from './components/elements/LoggedBar'; const App = () => { const [loggedBarVisible, setLoggedBarVisible] = React.useState('100vw'); + React.useEffect(() => { + console.log('czy zalogowany'); + console.log(KeyCloakService.isLoggedIn()); + }); + const loggedBarVisibleHandler = () => { if (loggedBarVisible === '0') setLoggedBarVisible('100vw'); diff --git a/src/api/loginTest.js b/src/api/loginTest.js deleted file mode 100644 index 8a48d2a..0000000 --- a/src/api/loginTest.js +++ /dev/null @@ -1,18 +0,0 @@ -const loginTest = () => { - let data = { - client_id: 'Id_of_your_client', - username: 'test', - password: 'test', - grant_type: 'password' - }; - - fetch('http://0.0.0.0:8080/auth/realms/test/protocol/openid-connect/token', { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify(data) - }).then(res => { - console.log('Request complete! response:', res); - }); -}; - -export default loginTest; \ No newline at end of file diff --git a/src/services/KeyCloakService.js b/src/services/KeyCloakService.js index 0e75627..5004872 100644 --- a/src/services/KeyCloakService.js +++ b/src/services/KeyCloakService.js @@ -1,9 +1,9 @@ import Keycloak from 'keycloak-js'; const _kc = new Keycloak({ - url: 'http://0.0.0.0:8080/', - realm: 'test', - clientId: 'test' + url: 'https://auth-dev.csi.wmi.amu.edu.pl/', + realm: 'gonito-dev', + clientId: 'gonito-dev-heroku' }); const initKeycloak = (onAuthenticatedCallback) => { @@ -13,8 +13,10 @@ const initKeycloak = (onAuthenticatedCallback) => { pkceMethod: 'S256', }) .then((authenticated) => { + console.log('user is authenticated!'); + console.log(isLoggedIn()); if (!authenticated) { - console.log('user is not authenticated..!'); + console.log('user is NOT authenticated..!'); } onAuthenticatedCallback(); })