Skip to content

Commit

Permalink
remove signout buttom
Browse files Browse the repository at this point in the history
  • Loading branch information
Konzisam committed Dec 9, 2024
1 parent 061bf18 commit 2f40c34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
36 changes: 10 additions & 26 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,21 @@ import { useAuth } from "react-oidc-context";
import Home from "./components/Home";
import { useNavigate } from "react-router-dom";
import { useEffect } from "react";
import { config } from "./config/env";
// import { config } from "./config/env";

const { client_id, localURL: logoutUri, cognitoDomain } = config;
// const { client_id, localURL: logoutUri, cognitoDomain } = config;

function App() {
const auth = useAuth();
const navigate = useNavigate();

console.log(auth);
// const signOutRedirect = () => {
// sessionStorage.clear();

const signOutRedirect = () => {
sessionStorage.clear();

window.location.href = `${cognitoDomain}/logout?client_id=${client_id}&logout_uri=${encodeURIComponent(
logoutUri
)}`;
};

const handleLogin = () => {
// Manually construct the signin URL to inspect it
const signinUrl = `${cognitoDomain}/oauth2/authorize?client_id=${client_id}&redirect_uri=${encodeURIComponent(
`${logoutUri}callback`
)}&response_type=code&scope=email+openid+phone`;

// Log the signin URL
console.log("Signin URL:", signinUrl);

// Proceed with the redirect
auth.signinRedirect();
};
// window.location.href = `${cognitoDomain}/logout?client_id=${client_id}&logout_uri=${encodeURIComponent(
// logoutUri
// )}`;
// };

useEffect(() => {
if (auth.isAuthenticated) {
Expand Down Expand Up @@ -68,9 +53,8 @@ function App() {
</div>
<h1>Car Price Estimator</h1>
<h3>Please Login to use</h3>
{/* <button onClick={() => auth.signinRedirect()}>Sign in / Register</button> */}
<button onClick={handleLogin}>Sign in / Register</button>
<button onClick={() => signOutRedirect()}>Sign out</button>
<button onClick={() => auth.signinRedirect()}>Sign in / Register</button>
{/* <button onClick={() => signOutRedirect()}>Sign out</button> */}
</div>
);
}
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import { config } from "./config/env.ts";

const { cognitoAuthority, client_id, localURL } = config;

const encodedRedirectUri = encodeURIComponent(`${localURL}callback`);
console.log(encodedRedirectUri);
console.log("authority:--->", cognitoAuthority, "<---")
console.log("--->",client_id,"<----")

const cognitoAuthConfig = {
authority: cognitoAuthority,
client_id,
Expand Down

0 comments on commit 2f40c34

Please sign in to comment.