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

MERL-1204: onLogout server action - app router #1557

Merged
merged 3 commits into from
Sep 1, 2023

Conversation

matthewguywright
Copy link
Contributor

Description

Created the onLogout server action for the app router.

Testing

To test this follow these steps:

  1. Pull this branch
  2. Run npm install
  3. Navigate in the terminal to the examples/next/app-router folder
  4. Setup the env.local and a local site for Faust. Be sure to set the frontend url in the Faust WP Plugin settings.
  5. Add the following to the app-router/app/page.js file inside the main element:
     // import up top
     import { onLogout } from '@faustwp/experimental-app-router';

     // inside the <main> body element
      <form action={onLogout}>
        <button type="submit">Logout</button>
      </form>
  1. Run npm install and then npm run build
  2. Run npm run dev -w @faustwp/app-router-example
  3. Navigate to your localhost:3000
  4. You should see your homepage with a logout button
  5. Add a cookie to your browser with dev tools called http://localhost:<yourLocalPortForLocalWPSite>-rt and give it any value
  6. Click on logout, the cookie should be deleted

@matthewguywright matthewguywright requested a review from a team as a code owner August 30, 2023 18:59
@github-actions
Copy link
Contributor

📦 Next.js Bundle Analysis for @faustwp/getting-started-example

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2023

⚠️ No Changeset found

Latest commit: ac6930d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@TeresaGobble
Copy link
Contributor

TeresaGobble commented Aug 31, 2023

Hi @matthewguywright , Nice work on this! Thank you for your thorough testing instructions too, that's always appreciated! 😊

I'm not seeing the cookie get deleted upon clicking the logout button. See the video below:

Screen.Recording.2023-08-31.at.5.22.20.PM.mov

Am I adding the cookie as expected? If so, perhaps we can test it in my environment to make sure everything looks as it should.

@blakewilson
Copy link
Contributor

blakewilson commented Aug 31, 2023

Hey @TeresaGobble, it looks like you are setting a refresh token with your front ends site URL. In this case it should be your WP sites address:

http://localhost:<yourLocalPortForLocalWPSite>-rt

For instance, my local WordPress site is http://headless.local, so my cookie name would be:

http://headless.local-rt 

(I like your video demo! That's very useful)

Copy link
Contributor

@TeresaGobble TeresaGobble left a comment

Choose a reason for hiding this comment

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

Thank you so much @blakewilson! That was the issue. This works as intended. Nicely done Matt! 👍

@matthewguywright matthewguywright merged commit 031eee6 into canary Sep 1, 2023
13 checks passed
@matthewguywright matthewguywright deleted the feature/mw-merl-1204-logout branch September 1, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants