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: When GCal OAuth Canceled, Do Not Create A Credential #11987

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

joeauyeung
Copy link
Contributor

What does this PR do?

This PR throws the correct error when a user cancels the OAuth flow when connecting GCal. While the error handling could be improved this will prevent errors for now and keeps our error handling consistent.

https://www.loom.com/share/b8412b0e6a134979afbc2d3e3015dde1

Fixes # (issue)

Requirement/Documentation

  • If there is a requirement document, please, share it here.
  • If there is ab UI/UX design document, please, share it here.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Go through the process of connecting a GCal
  • Cancel half way through
  • Go back to the installed page, the credential should not have been made

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

@joeauyeung joeauyeung requested a review from emrysal October 19, 2023 01:06
@vercel
Copy link

vercel bot commented Oct 19, 2023

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 Oct 19, 2023 1:14am
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 19, 2023 1:14am
cal-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 19, 2023 1:14am
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 19, 2023 1:14am
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 19, 2023 1:14am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Oct 19, 2023 1:14am

@github-actions
Copy link
Contributor

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

@zomars zomars added the core area: core, team members only label Oct 19, 2023
Comment on lines 41 to +52
const token = await oAuth2Client.getToken(code);
key = token.res?.data;
}

await prisma.credential.create({
data: {
type: "google_calendar",
key,
userId: req.session.user.id,
appId: "google-calendar",
},
});
await prisma.credential.create({
data: {
type: "google_calendar",
key,
userId: req.session.user.id,
appId: "google-calendar",
},
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added safety of only creating the credential if the code is valid

@github-actions
Copy link
Contributor

📦 Next.js Bundle Analysis for @calcom/web

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

This PR introduced no changes to the JavaScript bundle! 🙌

@deploysentinel
Copy link

deploysentinel bot commented Oct 19, 2023

Current Playwright Test Results Summary

✅ 162 Passing - ⚠️ 3 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 10/19/2023 01:15:46am UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 1e85a8f

Started: 10/19/2023 01:13:23am UTC

⚠️ Flakes

📄   apps/web/playwright/integrations-stripe.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Stripe integration When event is paid and confirmed Paid and confirmed booking should be able to be rescheduled
Retry 1Initial Attempt
0.75% (2) 2 / 266 runs
failed over last 7 days
3.01% (8) 8 / 266 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should be able to reschedule
Retry 1Initial Attempt
8.27% (23) 23 / 278 runs
failed over last 7 days
89.93% (250) 250 / 278 runs
flaked over last 7 days
Popup Tests should open embed iframe on click - Configured with light theme
Retry 1Initial Attempt
3.58% (10) 10 / 279 runs
failed over last 7 days
35.84% (100) 100 / 279 runs
flaked over last 7 days

View Detailed Build Results


Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

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

Noice

@zomars zomars merged commit 1bf56fb into main Oct 19, 2023
@zomars zomars deleted the gcal-on-cancel-throw-error branch October 19, 2023 01:35
@zomars zomars added the High priority Created by Linear-GitHub Sync label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only High priority Created by Linear-GitHub Sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants