Skip to content

Commit

Permalink
chore(token): disable never expiring tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Camalon <[email protected]>
  • Loading branch information
thbcmlowk committed Aug 6, 2024
1 parent 4734007 commit 421f7cf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/routes/tokens/BearerTokenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
export const parseToken = (object: RawBearerTokenT): BearerTokenT => {
return {
created_at: new Date(object.created_at),
expires_at: object.expires_at ? new Date(object.expires_at) : null,
expires_at: new Date(object.expires_at),
note: object.note,
id: object.id,
};
Expand All @@ -18,7 +18,7 @@ export const parseNewToken = (object: RawNewBearerTokenT): NewBearerTokenT => {
return {
token: object.token,
created_at: new Date(object.created_at),
expires_at: object.expires_at ? new Date(object.expires_at) : null,
expires_at: new Date(object.expires_at),
note: object.note,
id: object.id,
};
Expand Down
6 changes: 1 addition & 5 deletions src/routes/tokens/components/GenerateTokenModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const GenerateTokenModal = ({

const [tokenName, setTokenName] = useState('');
const [durationSelect, setDurationSelect] = useState('');
const [expirationDate, setExpirationDate] = useState<string | null>('');
const [expirationDate, setExpirationDate] = useState<string>('');

const incorrectExpiration =
expirationDate === '' ||
Expand All @@ -61,9 +61,6 @@ const GenerateTokenModal = ({
case '60days':
setExpirationDate(increaseDate(new Date(), 60).toISOString());
break;
case 'never':
setExpirationDate(null);
break;
case 'custom':
default:
break;
Expand Down Expand Up @@ -136,7 +133,6 @@ const GenerateTokenModal = ({
</option>
<option value="30days">30 days</option>
<option value="60days">60 days</option>
<option value="never">Never</option>
<option value="custom">Custom</option>
</Select>
{durationSelect === 'custom' && (
Expand Down
4 changes: 2 additions & 2 deletions src/types/BearerTokenTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type BearerTokenT = {
created_at: Date;
expires_at: Date | null;
expires_at: Date;
note: string;
id: string;
};
Expand All @@ -9,7 +9,7 @@ export type NewBearerTokenT = BearerTokenT & { token: string };
// API response
export type RawBearerTokenT = {
created_at: string;
expires_at: string | null;
expires_at: string;
note: string;
id: string;
};
Expand Down

0 comments on commit 421f7cf

Please sign in to comment.