cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

chore: redirect platform users to dashboard

Open Ryukemeister opened this issue 1 year ago • 7 comments
trafficstars

What does this PR do?

  • This PR adds a redirect for all platform clients to make sure that a platform user is not able to access any of the consumer related pages.

Mandatory Tasks (DO NOT REMOVE)

  • [x] I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • [x] I have added a Docs issue here if this PR makes changes that would require a documentation change
  • [ ] I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

How should this be tested?

Run the webapp on localhost, go to settings/platform/new and make a new platform client. Once that is done and billing is setup for platform, if we try to navigate to any of the pages such as /event-types or /availability we should automatically be redirected to /settings/platform

Ryukemeister avatar Jun 06 '24 19:06 Ryukemeister

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

:white_check_mark: ThyMinimalDev
:white_check_mark: keithwillcode
:white_check_mark: Ryukemeister
:x: Rajiv Sahal


Rajiv Sahal seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jun 06 '24 19:06 CLAassistant

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

github-actions[bot] avatar Jun 06 '24 19:06 github-actions[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2024 9:39pm
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jun 27, 2024 9:39pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jun 27, 2024 9:39pm

vercel[bot] avatar Jun 06 '24 19:06 vercel[bot]

Graphite Automations

"Add platform team as reviewer" took an action on this PR • (06/06/24)

1 reviewer was added to this PR based on Keith Williams's automation.

graphite-app[bot] avatar Jun 06 '24 19:06 graphite-app[bot]

is there any way we dont add this much platfrom related code to our core code base? 🤔

PeerRich avatar Jun 07 '24 17:06 PeerRich

is there any way we dont add this much platform related code to our core code base? 🤔

@PeerRich as a workaround for this I tried implementing the logic to redirect the users inside of getInitialProps, found a couple of blogs on how to do this inside of getInitialProps, one of them being this which I tried myself. The main issue I found with this approach is that in order to handle redirection inside of getInitialProps there are two cases, 1. server side redirection and 2. client side redirection which would add more code since we handle those two differently and that would just increase the amount of code which in turn we're trying to reduce. Also there's another issue with using getInitialProps for client side navigation

However, it's important to note that in client-side navigation scenarios, getInitialProps is not invoked for subsequent navigations to the same page within the application.

For these two reasons I think its better to do it this way inside of the component since we only have to do this once and the logic for redirecting can be stored in a custom hook. I've also added comments for the custom hook in case someone else wants to some changes to the _app.tsx in the future.

Ryukemeister avatar Jun 13 '24 06:06 Ryukemeister

E2E failing / flaky

PeerRich avatar Jun 13 '24 20:06 PeerRich

This PR is being marked as stale due to inactivity.

github-actions[bot] avatar Jul 12 '24 00:07 github-actions[bot]

Closing this PR due to staleness. Please reopen if work is to continue.

keithwillcode avatar Jul 29 '24 04:07 keithwillcode