✨ Added user lookup dependency injection to sso base adapter#29365
Conversation
WalkthroughSSOBase now supports an injected Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run @tryghost/admin-x-settings:test:acceptance |
✅ Succeeded | 8m 58s | View ↗ |
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 49s | View ↗ |
nx run-many -t test:unit -p ghost,@tryghost/ada... |
✅ Succeeded | 8m 34s | View ↗ |
nx run ghost:test:integration |
✅ Succeeded | 3m | View ↗ |
nx run ghost:test:legacy |
✅ Succeeded | 3m 18s | View ↗ |
nx run ghost-monorepo:lint:boundaries |
✅ Succeeded | 19s | View ↗ |
nx run-many -t lint -p ghost,@tryghost/adapter-... |
✅ Succeeded | 3m 52s | View ↗ |
nx run ghost:test:e2e |
✅ Succeeded | 3m 8s | View ↗ |
Additional runs (9) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-07-15 18:57:45 UTC
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #29365 +/- ##
==========================================
- Coverage 74.01% 74.00% -0.01%
==========================================
Files 1578 1578
Lines 137508 137524 +16
Branches 16650 16652 +2
==========================================
+ Hits 101777 101780 +3
- Misses 34684 34697 +13
Partials 1047 1047
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b963d17 to
5c4398a
Compare
ref https://linear.app/ghost/issue/PLA-233/create-public-npm-package-for-sso-adapter-base - adds new UserRepository type to SSO Base adapter, allowing calling code to inject model layer references into the base adapter without needing core requires - add @tryghost/errors dep to base adapter
5c4398a to
84245f9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/server/services/auth/session/index.js (1)
87-90: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
models.User.getOwner()for owner lookups.Ghost's
Usermodel provides a dedicatedgetOwner()method. Using it is preferred over duplicating the internalroleandstatusquery parameters withfindOne.♻️ Proposed refactor
- async getOwner() { - const owner = await models.User.findOne({role: 'Owner', status: 'all'}); - return owner ? {id: owner.id, email: owner.get('email')} : null; - } + async getOwner() { + const owner = await models.User.getOwner(); + return owner ? {id: owner.id, email: owner.get('email')} : null; + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ghost/core/core/server/services/auth/session/index.js` around lines 87 - 90, Update the getOwner() method to use the dedicated models.User.getOwner() lookup instead of duplicating role and status criteria through models.User.findOne. Preserve the existing return shape, including the owner id and email mapping or null when no owner exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ghost/core/core/server/services/auth/session/index.js`:
- Around line 87-90: Update the getOwner() method to use the dedicated
models.User.getOwner() lookup instead of duplicating role and status criteria
through models.User.findOne. Preserve the existing return shape, including the
owner id and email mapping or null when no owner exists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 08ff3baa-7793-4875-aba8-0787b655e127
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
ghost/core/core/server/services/auth/session/index.jsghost/core/package.jsonghost/core/test/e2e-api/admin/sso.test.jspackages/adapters/sso-base/package.jsonpackages/adapters/sso-base/src/base.tspackages/adapters/sso-base/test/index.test.tspnpm-workspace.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
- ghost/core/test/e2e-api/admin/sso.test.js
- packages/adapters/sso-base/src/base.ts
- packages/adapters/sso-base/test/index.test.ts

ref https://linear.app/ghost/issue/PLA-233/create-public-npm-package-for-sso-adapter-base