feat: new session api
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
import { Button } from "@renderer/components/ui/button"
|
||||
import { UserButton } from "@renderer/components/user-button"
|
||||
import { getCsrfToken, authConfigManager } from "@hono/auth-js/react"
|
||||
|
||||
export function Component() {
|
||||
const getCallbackUrl = async () => {
|
||||
const response = await (
|
||||
await fetch(
|
||||
`${authConfigManager.getConfig().baseUrl}/auth-app/new-session`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
csrfToken: await getCsrfToken(),
|
||||
}),
|
||||
},
|
||||
)
|
||||
).json()
|
||||
return `readok://auth?token=${response.data.sessionToken}`
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-screen w-full flex items-center justify-center flex-col gap-10">
|
||||
<UserButton />
|
||||
@@ -12,11 +32,13 @@ export function Component() {
|
||||
You have successfully connected to ReadOK Account. Now is the time to
|
||||
open ReadOK and safely close this page.
|
||||
</h2>
|
||||
<a href={`readok://todo`} className="flex flex-col gap-3">
|
||||
<Button className="text-lg" size="xl">
|
||||
Open ReadOK
|
||||
</Button>
|
||||
</a>
|
||||
<Button
|
||||
className="text-lg"
|
||||
size="xl"
|
||||
onClick={async () => window.open(await getCallbackUrl())}
|
||||
>
|
||||
Open ReadOK
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user