Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(token): disable never expiring tokens #385

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/385.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable never expiring user-generated tokens
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
Loading