mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 04:26:43 +00:00
fix(lint): fix some lint issues
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
import bcrypt from "bcrypt";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import bcrypt from "bcrypt"
|
|
||||||
|
|
||||||
import { SecretSharingSchema } from "@app/db/schemas";
|
import { SecretSharingSchema } from "@app/db/schemas";
|
||||||
import { SecretSharingAccessType } from "@app/lib/types";
|
import { SecretSharingAccessType } from "@app/lib/types";
|
||||||
@@ -124,11 +124,11 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>
|
|||||||
hashedHex,
|
hashedHex,
|
||||||
orgId: req.permission?.orgId
|
orgId: req.permission?.orgId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!sharedSecret) {
|
if (!sharedSecret) {
|
||||||
return { isValid: false };
|
return { isValid: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedSecret.password) {
|
if (sharedSecret.password) {
|
||||||
const isMatch = await bcrypt.compare(password, sharedSecret.password);
|
const isMatch = await bcrypt.compare(password, sharedSecret.password);
|
||||||
return { isValid: isMatch };
|
return { isValid: isMatch };
|
||||||
|
|||||||
@@ -77,19 +77,20 @@ export const useValidateSecretPassword = ({
|
|||||||
hashedHex: string;
|
hashedHex: string;
|
||||||
userPassword: string;
|
userPassword: string;
|
||||||
}) => {
|
}) => {
|
||||||
return useQuery({
|
return useQuery(
|
||||||
enabled: Boolean(sharedSecretId) && Boolean(userPassword),
|
[`validateSecretPass-${sharedSecretId}`],
|
||||||
queryKey: `validateSecretPass-${sharedSecretId}`,
|
async () => {
|
||||||
queryFn: async () => {
|
const { data } = await apiRequest.post<ValidateSecretPassword>(
|
||||||
const { data, isLoading, refetch } = await apiRequest.post<ValidateSecretPassword>(
|
|
||||||
`/api/v1/secret-sharing/public/${sharedSecretId}/validate`,
|
`/api/v1/secret-sharing/public/${sharedSecretId}/validate`,
|
||||||
{
|
{
|
||||||
hashedHex,
|
hashedHex,
|
||||||
password: userPassword
|
password: userPassword
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
return data;
|
||||||
return { data, isLoading, refetch }
|
},
|
||||||
|
{
|
||||||
|
enabled: Boolean(sharedSecretId) && Boolean(userPassword),
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export const ShareSecretForm = ({ isPublic, value }: Props) => {
|
|||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
>
|
>
|
||||||
<Input {...field} placeholder="Password" type="text" />
|
<Input {...field} placeholder="Password" type="password" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const ViewSecretPublicPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
{secret && (
|
{secret && (
|
||||||
!passMatches && secret.password ? (
|
!passMatches && secret.password ? (
|
||||||
<PasswordContainer secretId={id} hashedHex={hashedHex} handlePassMatch={handlePassMatch} />
|
<PasswordContainer secretId={id as string} hashedHex={hashedHex} handlePassMatch={handlePassMatch} />
|
||||||
) : (
|
) : (
|
||||||
key && <SecretContainer secret={secret} secretKey={key} />
|
key && <SecretContainer secret={secret} secretKey={key} />
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState, ChangeEvent } from "react";
|
import { useState, ChangeEvent } from "react";
|
||||||
|
|
||||||
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
|
import { faArrowRight, faSpinner } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon, faSpinner } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
import { Button, IconButton, Input } from "@app/components/v2";
|
import { Button, IconButton, Input } from "@app/components/v2";
|
||||||
import { useValidateSecretPassword } from "@app/hooks/api/secretSharing";
|
import { useValidateSecretPassword } from "@app/hooks/api/secretSharing";
|
||||||
@@ -27,10 +27,12 @@ export const PasswordContainer = ({ secretId, hashedHex, handlePassMatch }: Prop
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validatePassword = async () => {
|
const validatePassword = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data: freshData } = await refetch();
|
const { data: freshData } = await refetch();
|
||||||
|
|
||||||
if (freshData.data.isValid === true) {
|
if (freshData?.isValid === true) {
|
||||||
handlePassMatch(true);
|
handlePassMatch(true);
|
||||||
} else {
|
} else {
|
||||||
createNotification({
|
createNotification({
|
||||||
@@ -62,7 +64,10 @@ export const PasswordContainer = ({ secretId, hashedHex, handlePassMatch }: Prop
|
|||||||
validatePassword()
|
validatePassword()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={isLoading ? faSpinner : faArrowRight} />
|
<FontAwesomeIcon
|
||||||
|
className={isLoading ? 'fa-spin' : ''}
|
||||||
|
icon={isLoading ? faSpinner : faArrowRight}
|
||||||
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user