feat: check if secret is expired before checking if secret has password

This commit is contained in:
lemmyMwaura
2024-08-07 20:55:37 +03:00
parent 69fe5bf71d
commit b0a5023723
6 changed files with 42 additions and 34 deletions
@@ -6,7 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
import { Button, FormControl, IconButton, Input } from "@app/components/v2";
import { fetchSecretIfPasswordIsValid } from "@app/hooks/api/secretSharing";
import { fetchSecretIfPasswordIsValid, TViewSharedSecretResponse } from "@app/hooks/api/secretSharing";
import { createNotification } from "@app/components/notifications";
type Props = {
@@ -33,7 +33,7 @@ export const PasswordContainer = ({ secretId, hashedHex, handleSecret }: Props)
const onFormSubmit = async ({ password }: FormData) => {
try {
const secret = await fetchSecretIfPasswordIsValid(
const secret: TViewSharedSecretResponse = await fetchSecretIfPasswordIsValid(
secretId,
hashedHex,
password,
@@ -71,7 +71,7 @@ export const PasswordContainer = ({ secretId, hashedHex, handleSecret }: Props)
label="Password"
>
<div className="flex items-center gap-2 justify-between rounded-md">
<Input {...field} placeholder="Enter Password to view secret"></Input>
<Input {...field} placeholder="Enter Password to view secret" type="password"></Input>
<div className="flex">
<IconButton
ariaLabel="copy icon"