mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00: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
|
|
@ -41,6 +41,7 @@ const EXPIRY = {
|
|||
ONE_DAY: { display: 'in 1 day', value: 24 * 60 * 60 * 1000 },
|
||||
ONE_WEEK: { display: 'in 7 days', value: 7 * 24 * 60 * 60 * 1000 },
|
||||
ONE_MONTH: { display: 'in 30 days', value: 30 * 24 * 60 * 60 * 1000 },
|
||||
NEVER: { display: 'never', value: 0 },
|
||||
};
|
||||
|
||||
const SetKeyDialog = ({
|
||||
|
|
@ -84,7 +85,13 @@ const SetKeyDialog = ({
|
|||
|
||||
const submit = () => {
|
||||
const selectedOption = expirationOptions.find((option) => option.display === expiresAtLabel);
|
||||
const expiresAt = Date.now() + (selectedOption ? selectedOption.value : 0);
|
||||
let expiresAt;
|
||||
|
||||
if (selectedOption?.value === 0) {
|
||||
expiresAt = null;
|
||||
} else {
|
||||
expiresAt = Date.now() + (selectedOption ? selectedOption.value : 0);
|
||||
}
|
||||
|
||||
const saveKey = (key: string) => {
|
||||
saveUserKey(key, expiresAt);
|
||||
|
|
@ -160,12 +167,12 @@ const SetKeyDialog = ({
|
|||
main={
|
||||
<div className="grid w-full items-center gap-2">
|
||||
<small className="text-red-600">
|
||||
{`${localize('com_endpoint_config_key_encryption')} ${
|
||||
!expiryTime
|
||||
? localize('com_endpoint_config_key_expiry')
|
||||
: `${new Date(expiryTime).toLocaleString()}`
|
||||
}`}
|
||||
</small>
|
||||
{expiryTime === 'never'
|
||||
? localize('com_endpoint_config_key_never_expires')
|
||||
: `${localize('com_endpoint_config_key_encryption')} ${new Date(
|
||||
expiryTime,
|
||||
).toLocaleString()}`}
|
||||
</small>{' '}
|
||||
<Dropdown
|
||||
label="Expires "
|
||||
value={expiresAtLabel}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue