mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 09:50:15 +01:00
🔑 feat: infinite key expiry (#3252)
This commit is contained in:
parent
1aad315de6
commit
1edbfdbce2
4 changed files with 37 additions and 23 deletions
|
|
@ -21,16 +21,17 @@ const useUserKey = (endpoint: string) => {
|
|||
|
||||
const updateKey = useUpdateUserKeysMutation();
|
||||
const checkUserKey = useUserKeyQuery(keyName);
|
||||
|
||||
const getExpiry = useCallback(() => {
|
||||
if (checkUserKey.data) {
|
||||
return checkUserKey.data.expiresAt;
|
||||
return checkUserKey.data?.expiresAt || 'never';
|
||||
}
|
||||
}, [checkUserKey.data]);
|
||||
|
||||
const checkExpiry = useCallback(() => {
|
||||
const expiresAt = getExpiry();
|
||||
if (!expiresAt) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const expiresAtDate = new Date(expiresAt);
|
||||
|
|
@ -41,8 +42,8 @@ const useUserKey = (endpoint: string) => {
|
|||
}, [getExpiry]);
|
||||
|
||||
const saveUserKey = useCallback(
|
||||
(userKey: string, expiresAt: number) => {
|
||||
const dateStr = new Date(expiresAt).toISOString();
|
||||
(userKey: string, expiresAt: number | null) => {
|
||||
const dateStr = expiresAt ? new Date(expiresAt).toISOString() : '';
|
||||
updateKey.mutate({
|
||||
name: keyName,
|
||||
value: userKey,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue