Skip to content

Commit

Permalink
Using signoutRedirect()
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Nov 26, 2024
1 parent 004d75d commit 4f7c33e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 10 additions & 2 deletions components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export default function Header() {
const auth = useAuth();
const navigate = useNavigate();

console.log(auth);

return (
<div className="logo">
<h1 onClick={() => navigate("/")}>Raman spectra search</h1>
Expand All @@ -22,7 +24,11 @@ export default function Header() {
<button
className="shareBtn"
style={{ marginLeft: "18px" }}
onClick={() => void auth.removeUser()}
onClick={() => {
// auth.removeUser();
// localStorage.clear();
auth.signoutRedirect();
}}
>
Log out
</button>
Expand All @@ -31,7 +37,9 @@ export default function Header() {
<button
className="shareBtn"
style={{ marginLeft: "18px" }}
onClick={() => void auth.signinRedirect()}
onClick={() => {
auth.signinRedirect();
}}
>
Log in
</button>
Expand Down
16 changes: 9 additions & 7 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import { AuthProvider, useAuth } from "react-oidc-context";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { AuthProvider } from "react-oidc-context";
import { useAuth } from "react-oidc-context";

import ReactDOM from "react-dom/client";
import App from "./App.jsx";
Expand All @@ -11,7 +10,7 @@ const oidcConfig = {
authority: "https://iam.ideaconsult.net/auth/realms/nano",
client_id: "idea-ui",
redirect_uri: window.location.origin + "/search/",
post_logout_redirect_uri: "https://iam.ideaconsult.net/",
post_logout_redirect_uri: window.location.origin + "/search/",
response_type: "code",
scope: "openid profile email",
};
Expand All @@ -38,9 +37,12 @@ const Main = () => {
const registerServiceWorker = async () => {
if ("serviceWorker" in navigator) {
try {
const registration = await navigator.serviceWorker.register(base_url, {
scope: "/search/",
});
const registration = await navigator.serviceWorker.register(
"/search/serviceWorker.js",
{
scope: "/search/",
}
);

await registration.active.postMessage({
type: "TOKEN",
Expand Down

0 comments on commit 4f7c33e

Please sign in to comment.