Skip to content
Snippets Groups Projects
Commit e5f06fc7 authored by Luka's avatar Luka
Browse files

Add hydra public url to environment

parent 165998cf
No related branches found
No related tags found
1 merge request!32Dashboard logout should trigger OAuth logout endpoint
Pipeline #19033 passed with stages
in 3 minutes and 1 second
REACT_APP_API_URL=http://127.0.0.1:5000/api/v1
REACT_APP_HYDRA_PUBLIC_URL=https://sso.init.stackspin.net
\ No newline at end of file
......@@ -2,7 +2,6 @@ import React, { Fragment, useState } from 'react';
import { Disclosure, Menu, Transition } from '@headlessui/react';
import { MenuIcon, XIcon } from '@heroicons/react/outline';
import { useAuth } from 'src/services/auth';
import { getDomainName } from 'src/common/util';
import Gravatar from 'react-gravatar';
import { Link, useLocation } from 'react-router-dom';
import clsx from 'clsx';
......@@ -25,6 +24,8 @@ function filterNavigationByDashboardRole(isAdmin: boolean) {
return navigation.filter((item) => !item.requiresAdmin);
}
const HYDRA_URL = process.env.REACT_APP_HYDRA_PUBLIC_URL;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface HeaderProps {}
......@@ -32,24 +33,6 @@ const Header: React.FC<HeaderProps> = () => {
const [currentUserModal, setCurrentUserModal] = useState(false);
const { logOut, currentUser, isAdmin } = useAuth();
const singOutUrl = () => {
const { hostname } = window.location;
const domain = getDomainName(window.location.hostname);
let url = `https://sso.${domain}/oauth2/sessions/logout`;
// This is a fix so it can work with dashboard.init.stackspin.net
if (hostname.includes('init')) {
url = `https://sso.init.${domain}/oauth2/sessions/logout`;
}
// This is a fix so it can work locally
if (hostname.includes('localhost')) {
url = 'https://sso.init.stackspin.net/oauth2/sessions/logout';
}
return url;
};
const { pathname } = useLocation();
const currentUserModalOpen = () => {
......@@ -59,6 +42,8 @@ const Header: React.FC<HeaderProps> = () => {
const navigationItems = filterNavigationByDashboardRole(isAdmin);
const singOutUrl = `${HYDRA_URL}/oauth2/sessions/logout`;
return (
<>
<Disclosure as="nav" className="bg-white shadow relative z-10">
......@@ -139,7 +124,7 @@ const Header: React.FC<HeaderProps> = () => {
{({ active }) => (
<a
onClick={() => logOut()}
href={singOutUrl()}
href={singOutUrl}
className={classNames(
active ? 'bg-gray-100 cursor-pointer' : '',
'block px-4 py-2 text-sm text-gray-700 cursor-pointer',
......
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