mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 13:28:27 +00:00
misc: added validate connection and account logic
This commit is contained in:
+22
-13
@@ -1,5 +1,5 @@
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { Button, ModalClose } from "@app/components/v2";
|
||||
@@ -30,23 +30,32 @@ type FormData = z.infer<typeof formSchema>;
|
||||
export const SSHAccountForm = ({ account, onSubmit }: Props) => {
|
||||
const isUpdate = Boolean(account);
|
||||
|
||||
const getDefaultCredentials = () => {
|
||||
if (!account) return undefined;
|
||||
|
||||
if (account.credentials.authMethod === SSHAuthMethod.Password) {
|
||||
return {
|
||||
...account.credentials,
|
||||
password: UNCHANGED_PASSWORD_SENTINEL
|
||||
};
|
||||
}
|
||||
|
||||
if (account.credentials.authMethod === SSHAuthMethod.PublicKey) {
|
||||
return {
|
||||
...account.credentials,
|
||||
privateKey: UNCHANGED_PASSWORD_SENTINEL
|
||||
};
|
||||
}
|
||||
|
||||
return account.credentials;
|
||||
};
|
||||
|
||||
const form = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: account
|
||||
? {
|
||||
...account,
|
||||
credentials:
|
||||
account.credentials.authMethod === SSHAuthMethod.Password
|
||||
? {
|
||||
...account.credentials,
|
||||
password: UNCHANGED_PASSWORD_SENTINEL
|
||||
}
|
||||
: account.credentials.authMethod === SSHAuthMethod.PublicKey
|
||||
? {
|
||||
...account.credentials,
|
||||
privateKey: UNCHANGED_PASSWORD_SENTINEL
|
||||
}
|
||||
: account.credentials
|
||||
credentials: getDefaultCredentials()
|
||||
}
|
||||
: {
|
||||
name: "",
|
||||
|
||||
@@ -177,14 +177,14 @@ export const PamSessionRow = ({ session, search, filteredLogs }: Props) => {
|
||||
{filteredLogs.length > 0 && (
|
||||
<Tr>
|
||||
<Td colSpan={5} className="py-3 text-xs">
|
||||
{logsToShow.map((log, idx) => {
|
||||
{logsToShow.map((log) => {
|
||||
// Handle command logs (database sessions)
|
||||
if ("input" in log && "output" in log) {
|
||||
const formattedInput = formatLogContent(log.input);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={`${id}-log-${log.timestamp}-${idx}`}
|
||||
key={`${id}-log-${log.timestamp}`}
|
||||
className="mb-4 flex flex-col gap-1 last:mb-0"
|
||||
>
|
||||
<div className="flex items-center gap-1.5 text-bunker-400">
|
||||
@@ -206,7 +206,7 @@ export const PamSessionRow = ({ session, search, filteredLogs }: Props) => {
|
||||
if ("data" in log && typeof log.data === "string") {
|
||||
return (
|
||||
<div
|
||||
key={`${id}-log-${log.timestamp}-${idx}`}
|
||||
key={`${id}-log-${log.timestamp}`}
|
||||
className="mb-4 flex flex-col gap-1 last:mb-0"
|
||||
>
|
||||
<div className="flex items-center gap-1.5 text-bunker-400">
|
||||
|
||||
Reference in New Issue
Block a user