Title: fix(auth): return 403 instead of 500 for blocked sign-in/sign-up attempts by waleedlatif1 · Pull Request #4783 · simstudioai/sim · GitHub
Open Graph Title: fix(auth): return 403 instead of 500 for blocked sign-in/sign-up attempts by waleedlatif1 · Pull Request #4783 · simstudioai/sim
X Title: fix(auth): return 403 instead of 500 for blocked sign-in/sign-up attempts by waleedlatif1 · Pull Request #4783 · simstudioai/sim
Description: Summary The hooks.before auth middleware threw plain Errors for the four auth-policy gates (registration disabled, email/password disabled, login allowlist, blocked signup domains). better-auth surfaces an uncaught hook Error as a generic 500 SERVER_ERROR, so a user hitting one of these gates saw "Failed to create account" with no actionable reason. Switched those four throws to APIError('FORBIDDEN', { message }) so the endpoints return a clean 403 with the policy message, which the client surfaces directly. Genuine internal/server failures (reset-password & OTP email send, provider getUserInfo fetch, Microsoft ID-token parse) intentionally remain plain Errors so they keep surfacing as 500s. How this was found Staging POST /api/auth/sign-up/email returned 500 for a @gmail.com signup. Staging has ALLOWED_LOGIN_DOMAINS=sim.ai, so Sim's allowlist gate correctly rejected the email — but as a 500 instead of a readable 403. The rejection itself is correct; only the status/message was wrong. Type of Change Bug fix Testing bun run type-check clean (confirms APIError resolves from better-auth/api and 'FORBIDDEN' is a valid status) bun run test app/api/auth/ — 60/60 passing bun run lint clean Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary The hooks.before auth middleware threw plain Errors for the four auth-policy gates (registration disabled, email/password disabled, login allowlist, blocked signup domains). better-auth su...
X Description: Summary The hooks.before auth middleware threw plain Errors for the four auth-policy gates (registration disabled, email/password disabled, login allowlist, blocked signup domains). better-auth su...
Opengraph URL: https://github.com/simstudioai/sim/pull/4783
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:468d311d-b796-f44f-0207-11b4bf2b70b2 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C088:1C88A1:CD76C6:12247A0:6AFB5E2D |
| html-safe-nonce | 83d4a57122dc627a5fca9f195de75a8958238fad5631ab797b1a4fc908efac57 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDg4OjFDODhBMTpDRDc2QzY6MTIyNDdBMDo2QUZCNUUyRCIsInZpc2l0b3JfaWQiOiIyMzg1OTI4OTI1NDE5ODg4MTczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5eb9bbdf2b655014d9a21a6969f8bb357482eda4111147d753dd7aded7a2ce4c |
| hovercard-subject-tag | pull_request:3765699434 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/4783/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary The hooks.before auth middleware threw plain Errors for the four auth-policy gates (registration disabled, email/password disabled, login allowlist, blocked signup domains). better-auth su... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width