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
@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TSharedSecret, TViewSharedSecretResponse, ValidateSecretPassword } from "./types";
import { TSharedSecret, TViewSharedSecretResponse } from "./types";
export const secretSharingKeys = {
allSharedSecrets: () => ["sharedSecrets"] as const,
@@ -77,7 +77,7 @@ export const fetchSecretIfPasswordIsValid = async (
hashedHex: string,
password: string,
) => {
const { data } = await apiRequest.post<ValidateSecretPassword>(
const { data } = await apiRequest.post<TViewSharedSecretResponse>(
`/api/v1/secret-sharing/public/${sharedSecretId}/validate`,
{
hashedHex,
@@ -31,7 +31,6 @@ export type TViewSharedSecretResponse = {
tag: string;
accessType: SecretSharingAccessType;
orgName?: string;
password?: string;
};
export type TDeleteSharedSecretRequest = {
@@ -41,8 +40,4 @@ export type TDeleteSharedSecretRequest = {
export enum SecretSharingAccessType {
Anyone = "anyone",
Organization = "organization"
}
export type ValidateSecretPassword = {
isValid: boolean
}
}