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

fix: get logout page working again #50

Merged
merged 2 commits into from
Dec 1, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@ucanto/core": "^9.0.0",
"@ucanto/interface": "^9.0.0",
"@ucanto/transport": "^9.0.0",
"@w3ui/react": "^1.0.1",
"@w3ui/react": "^1.1.0",
"@web3-storage/content-claims": "^3.2.1",
"@web3-storage/data-segment": "^5.0.0",
"ariakit-utils": "0.17.0-next.27",
Expand Down
56 changes: 11 additions & 45 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions src/app/logout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
'use client'
//import { useW3 } from "@w3ui/react"
import { useW3 } from "@w3ui/react"
import { useRouter } from "next/navigation"
import { useEffect } from "react"

export default function LogoutPage () {
//const [, { unloadAgent }] = useW3()
const [, { logout }] = useW3()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a client method? I assume we'd want this in w3cli also?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementing logout in the client would probably help simplify this method:

https://github.com/web3-storage/w3ui/blob/main/packages/react/src/providers/Provider.tsx#L76

but I think we'd still need something at this level because we need to clear the client, space, and accounts state

Copy link
Member Author

@travis travis Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could probably use the same event trick to clear space and accounts, but afaict Client isn't really meant to be mutable, and the creating a new private key is something that happens during Client creation, so we really do need something that can throw away the old client and create a new one, which I don't think can happen inside a Client method


function unloadAgent(){
// TODO need to figure out how this will work with the new library
}
const router = useRouter()
useEffect(function () {
if (unloadAgent) {
if (logout) {
async function logOutAndRedirect () {
await unloadAgent()
await logout()
router.push('/')
}
logOutAndRedirect()
Expand Down
Loading