meshery / play

Cloud Native Playground for Kubernetes and all CNCF projects
https://play.meshery.io
Apache License 2.0
91 stars 90 forks source link

Inappropriate Display of Signup Button for Users with Cookies #177

Closed captain-Akshay closed 2 months ago

captain-Akshay commented 5 months ago

Current Behavior

The website currently displays a signup button regardless of whether the user has an account indicating prior signup. This behavior is not consistent with user expectations and may lead to confusion.

Possible Solution:

Implement logic to check for the presence of a signup-related cookie. If the cookie is present, do not display the signup button. Ensure this check is performed consistently across page loads.

Screenshots/Logs

image

Environment


Contributor Guides and Resources

prajjwalyd commented 5 months ago

Hello!

I've been exploring the signup button behavior issue, and I'd like to propose a solution:

Step 1: Check for the presence of the signup-related cookie on mount.

Step 2: Initialize the showSignUpButton state based on the presence of the cookie.

Step 3: When the user submits the signup form, set the signup-related cookie, and update the showSignUpButton state accordingly.


If this solution aligns with your expectations, I'd be excited to take ownership of this issue and work on implementing it. Please let me know if any adjustments are needed or if you have any specific considerations...

prajjwalyd commented 5 months ago

Hey @captain-Akshay , any updates on this issue? Is it still valid?

Shabab007 commented 4 months ago

Hello @captain-Akshay @leecalcote I have looked into the issue . achieving the desired functionality of checking the presence of the signup-related cookie for not displaying the signup button involves a series of critical steps. . here are some findings

  1. After signing up the api response header is setting the http only cookie named "__cf_bm" which is expected. here is the screenshot
Screenshot 2024-02-08 at 7 09 37β€―PM
  1. Given that this application is crafted with Create React App (CRA), a client-side application, the inherent limitation is that JavaScript cannot access or retrieve HTTP-only cookies directly. Consequently, determining the user's cookie status becomes a challenge.

To address this, impactful suggestions include:

leecalcote commented 4 months ago

Hey @captain-Akshay , any updates on this issue? Is it still valid?

Yes, indeed, it certainly is.

leecalcote commented 4 months ago

The need here isn't with respect as to whether someone has signed up, but whether they have been awarded access to the Playground or not. The cookie for this will come from meshery.layer5.io. While you're digging in here, @Shabab007, please note the sibling issue here - https://github.com/layer5io/layer5/issues/5295. We'll want for these to both be handled in the same way. Both sites use Gatsby and both will need to look for the same cookie/access/token.

Shabab007 commented 4 months ago

Hi @leecalcote , After carefully looking at the issue and sibling issue . I found that playground is in different domain play.meshery.io and the cookie we are expecting that should come from meshery.layer5.io domain. Indeed, cookies are typically restricted to the domain from which they were set due to the same-origin policy, a security measure implemented by web browsers. Thats why we can't access the cookies from different domain to toggle off the playground button.

leecalcote commented 4 months ago

Maybe, maybe not.

leecalcote commented 4 months ago

My money is on the latter.

prajjwalyd commented 4 months ago

@leecalcote From what I've understood, the goal here is to show the signup button based on the presence of a cookie that will come from meshery.layer5.io, but we want to access that from https://play.meshery.io/... in this situation, I think @Shabab007's concern is spot on as we can't access cookies between domains without any Centralized Authentication or cross-domain messaging kind of things. Please correct me if I've misunderstood anything.

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 months ago

This issue is being automatically closed due to inactivity. However, you may choose to reopen this issue.