Skip to content

feat: impersonation improvements#13066

Merged
Udit-takkar merged 16 commits into
mainfrom
feat/impersonation-improvements
Jan 16, 2024
Merged

feat: impersonation improvements#13066
Udit-takkar merged 16 commits into
mainfrom
feat/impersonation-improvements

Conversation

@sean-brydon
Copy link
Copy Markdown
Member

@sean-brydon sean-brydon commented Jan 6, 2024

What does this PR do?

Fixes SAL-77

Loom Video: https://www.loom.com/share/9f69dec44bb74677838038bd4982bf7f

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)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Tests (Unit/Integration/E2E or any other test)
  • This change requires a documentation update

How should this be tested?

  1. Login as admin -> impersonate user -> return to admin
  2. Login as account connected to org -> impersonate member -> return to org account
  3. Login as team owner -> impersonate member -> logged out

@linear
Copy link
Copy Markdown

linear Bot commented Jan 6, 2024

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 6, 2024

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 Jan 16, 2024 8:32am
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2024 8:32am
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2024 8:32am
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jan 16, 2024 8:32am
cal-demo ⬜️ Ignored (Inspect) Visit Preview Jan 16, 2024 8:32am
qa ⬜️ Ignored (Inspect) Visit Preview Jan 16, 2024 8:32am
ui ⬜️ Ignored (Inspect) Visit Preview Jan 16, 2024 8:32am

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 6, 2024

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

@keithwillcode keithwillcode added the core area: core, team members only label Jan 6, 2024
Comment thread apps/web/playwright/impersonation.e2e.ts Outdated
<a className="border-b border-b-black" href="/auth/logout">
{t("impersonating_stop_instructions")}
</a>
canReturnToSelf ? (
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Validation also happens on BE just easier to handle this signout functionality here than within the custom provider from next-auth

export function checkUserIdentifier(creds: Partial<Credentials>) {
if (!creds?.username) throw new Error("User identifier must be present");
if (!creds?.username) {
if (creds?.returnToId) return;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If there is no username and a returnToId -> we dont need to throw here


if (returningUser) {
// Skip for none org users
if (returningUser.role !== "ADMIN" && !returningUser.organizationId) return;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ensure this can only be used by admins and if you are in an org

Comment on lines +17 to +20
impersonatedBy?: {
id: number;
role: PrismaUser["role"];
};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Easier to handle FE permissions when in impersonation

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 6, 2024

📦 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! 🙌

@pumfleet
Copy link
Copy Markdown
Contributor

pumfleet commented Jan 6, 2024

Wow this looks like a way snappier experience! I love it

Copy link
Copy Markdown
Contributor

@keithwillcode keithwillcode left a comment

Choose a reason for hiding this comment

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

IMG_0409

Downstream API build is failing

@keithwillcode keithwillcode modified the milestones: v3.7, v3.8 Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge consumer core area: core, team members only 🧹 Improvements Improvements to existing features. Mostly UX/UI Medium priority Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants