Skip to content

Commit

Permalink
feat: added logout button
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-rm-meyer-ISST committed Dec 6, 2023
1 parent 06e53b2 commit 61f8679
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
24 changes: 18 additions & 6 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ import {RouterLink, RouterView} from "vue-router";
<div class="flex flex-col justify-between mt-6">
<aside>
<ul class="space-y-2">
<li
v-for="route in viewsWithAccess"
key="route.name"
>
<li v-for="route in viewsWithAccess" key="route.name">
<RouterLink
class="flex items-center px-4 py-2 text-gray-700 bg-gray-100 dark:text-gray-100 dark:bg-gray-700 rounded-md"
:to="route.path"
Expand All @@ -50,6 +47,17 @@ import {RouterLink, RouterView} from "vue-router";
/>{{ route.name }}</RouterLink
>
</li>
<li
class="flex items-center px-4 py-2 text-gray-700 bg-gray-100 dark:text-gray-100 dark:bg-gray-700 rounded-md"
>
<button @click="logout">
<img
class="mr-2"
:src="TrashIcon"
alt="Icon"
/>Logout
</button>
</li>
</ul>
</aside>
</div>
Expand All @@ -65,7 +73,7 @@ import {RouterLink, RouterView} from "vue-router";
#app {
max-width: 1280px;
margin: 0px auto 0px 16rem;
margin: 0 auto 0 16rem;
padding: 2rem;
font-weight: normal;
Expand Down Expand Up @@ -167,7 +175,8 @@ import ManageIcon from "@/assets/icons/manage.svg";
import CatalogIcon from "@/assets/icons/catalog.svg";
import ResponsesIcon from "@/assets/icons/responses.svg";
import StockIcon from "@/assets/icons/stock.svg";
import TrashIcon from "@/assets/icons/trash.svg";
import AuthenticationService from "@/services/AuthenticationService";
export default {
name: "StockView",
Expand Down Expand Up @@ -196,6 +205,9 @@ export default {
};
return imageMap[routeName.toLowerCase()];
},
logout() {
AuthenticationService.logout();
},
},
};
</script>
9 changes: 4 additions & 5 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import Config from "./config.json";

import AuthenticationService from "./services/AuthenticationService.js";

AuthenticationService
.init()
AuthenticationService.init()
.then(() => {
console.info("User is authenticated, init application");

Expand All @@ -39,7 +38,9 @@ AuthenticationService
app.use(router);
app.use(JsonViewer);

console.debug("config.json BACKEND_BASE_URL=" + Config.BACKEND_BASE_URL);
console.debug(
"config.json BACKEND_BASE_URL=" + Config.BACKEND_BASE_URL
);
console.debug(".env.x VITE_BASE_URL=" + import.meta.env.VITE_BASE_URL);

app.mount("#app");
Expand All @@ -48,5 +49,3 @@ AuthenticationService
.catch((error) => {
console.log(error);
});

window.authService = AuthenticationService;
3 changes: 3 additions & 0 deletions frontend/src/services/AuthenticationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ const userHasRole = (requiredRoles) => {
};

const logout = () => {
if (!isEnabled){
return;
}
keycloak
.logout()
.then((success) => {
Expand Down
2 changes: 1 addition & 1 deletion local/keycloak/puris-config/Catena-X-realm.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
"protocol" : "openid-connect",
"attributes" : {
"client.secret.creation.time" : "1701016951",
"post.logout.redirect.uris" : "http://localhost:10081",
"post.logout.redirect.uris" : "",
"oauth2.device.authorization.grant.enabled" : "false",
"backchannel.logout.revoke.offline.tokens" : "false",
"use.refresh.tokens" : "true",
Expand Down

0 comments on commit 61f8679

Please sign in to comment.