mirror of
https://github.com/Infisical/infisical.git
synced 2025-03-28 15:29:21 +00:00
Formatting and navigating to select org
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import axios from "axios"
|
||||
import axios from "axios";
|
||||
|
||||
import { fetchUserDetails } from "@app/hooks/api/users/queries";
|
||||
import { getAuthToken, isLoggedIn } from "@app/reactQuery";
|
||||
@ -13,31 +13,36 @@ import {
|
||||
import { navigateUserToOrg } from "./Login.utils";
|
||||
|
||||
export const Login = () => {
|
||||
const router = useRouter();
|
||||
const [step, setStep] = useState(0);
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
const queryParams = new URLSearchParams(window.location.search)
|
||||
|
||||
useEffect(() => {
|
||||
const router = useRouter();
|
||||
const [step, setStep] = useState(0);
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
const queryParams = new URLSearchParams(window.location.search);
|
||||
|
||||
useEffect(() => {
|
||||
// TODO(akhilmhdh): workspace will be controlled by a workspace context
|
||||
const redirectToDashboard = async () => {
|
||||
// TODO(daniel): Move this to select-organization page.
|
||||
try {
|
||||
// user details
|
||||
const userDetails = await fetchUserDetails()
|
||||
const userDetails = await fetchUserDetails();
|
||||
// send details back to client
|
||||
|
||||
if (queryParams && queryParams.get("callback_port")) {
|
||||
const callbackPort = queryParams.get("callback_port")
|
||||
const callbackPort = queryParams.get("callback_port");
|
||||
|
||||
// send post request to cli with details
|
||||
const cliUrl = `http://127.0.0.1:${callbackPort}/`
|
||||
const instance = axios.create()
|
||||
await instance.post(cliUrl, { email: userDetails.email, privateKey: localStorage.getItem("PRIVATE_KEY"), JTWToken: getAuthToken() })
|
||||
const cliUrl = `http://127.0.0.1:${callbackPort}/`;
|
||||
const instance = axios.create();
|
||||
await instance.post(cliUrl, {
|
||||
email: userDetails.email,
|
||||
privateKey: localStorage.getItem("PRIVATE_KEY"),
|
||||
JTWToken: getAuthToken()
|
||||
});
|
||||
}
|
||||
|
||||
await navigateUserToOrg(router);
|
||||
navigateUserToSelectOrg(router);
|
||||
} catch (error) {
|
||||
console.log("Error - Not logged in yet");
|
||||
}
|
||||
@ -80,10 +85,7 @@ export const Login = () => {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{renderView()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return <div>{renderView()}</div>;
|
||||
};
|
||||
|
Reference in New Issue
Block a user