-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add debug button for the authentication bug
- Loading branch information
Showing
6 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use server'; | ||
|
||
import {auth} from '@clerk/nextjs'; | ||
import {jwtDecode} from 'jwt-decode'; | ||
|
||
const dateTimeFormat = new Intl.DateTimeFormat('nl', { | ||
dateStyle: 'full', | ||
timeStyle: 'long', | ||
}); | ||
|
||
export async function backendLogAction() { | ||
const {getToken, sessionId, session, userId} = await auth(); | ||
const token = await getToken(); | ||
const tokenDecoded = token ? jwtDecode(token) : null; | ||
const date = dateTimeFormat.format(tokenDecoded?.exp * 1000); | ||
console.log('DEBUG BUTTON CLICKED: BACKEND', { | ||
date, | ||
token, | ||
tokenDecoded, | ||
sessionId, | ||
session, | ||
userId, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client'; | ||
|
||
import {backendLogAction} from './backend'; | ||
import {useAuth} from '@clerk/nextjs'; | ||
import {jwtDecode} from 'jwt-decode'; | ||
import {useNotifications} from '@colonial-collections/ui'; | ||
|
||
const dateTimeFormat = new Intl.DateTimeFormat('nl', { | ||
dateStyle: 'full', | ||
timeStyle: 'long', | ||
}); | ||
|
||
export function DebugButton() { | ||
const {isSignedIn, getToken, sessionId} = useAuth(); | ||
const {addNotification} = useNotifications(); | ||
|
||
const onClick = async () => { | ||
const token = await getToken(); | ||
const tokenDecoded = token ? jwtDecode(token) : null; | ||
const date = dateTimeFormat.format(tokenDecoded?.exp * 1000); | ||
console.log('DEBUG BUTTON CLICKED: FRONTEND', { | ||
date, | ||
isSignedIn, | ||
token, | ||
tokenDecoded, | ||
sessionId, | ||
}); | ||
backendLogAction(); | ||
addNotification({ | ||
id: 'debugButtonClicked', | ||
message: 'Your data has been logged, please let Barbara know.', | ||
type: 'success', | ||
}); | ||
}; | ||
return ( | ||
<button | ||
className="p-1 sm:py-2 sm:px-3 rounded-full text-xs bg-neutral-200 hover:bg-neutral-300 text-neutral-800 transition flex items-center gap-1" | ||
onClick={onClick} | ||
> | ||
BUG report: I don't see edit buttons | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {DebugButton} from './frontend'; | ||
import {Notifications} from '@colonial-collections/ui'; | ||
|
||
export default function DebugPage() { | ||
return ( | ||
<div> | ||
<h1>Debug</h1> | ||
<Notifications /> | ||
<p>Debug page</p> | ||
<DebugButton /> | ||
</div> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
c396894
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
colonial-collections-dataset-browser – ./apps/dataset-browser
colonial-collections-dataset-browser-colonial-heritage.vercel.app
colonial-collections-dataset-browser-git-main-colonial-heritage.vercel.app
colonial-collections-dataset-browser.vercel.app
datasets.colonialcollections.nl