Repository navigation
[feature] replace bare 403 with a sign-in / switch-account page - #9
Merged
Merged
Conversation
Member-gated pages answered a signed-out or wrong-account visitor with a plain-text "forbidden" (documents) or a 404 (workspace pages), leaving no way forward. They now redirect to /access, which: - signed out: offers Google sign-in and returns to the original page - signed in as a non-member: shows the current email, offers switching account or signing out, and lists the workspaces this account can open /access is also the post-login callback, so picking another wrong account lands back on the explanation instead of a dead end. The Google provider now always shows the account chooser; otherwise signing out to switch would silently sign the same account back in. next is restricted to same-origin paths to avoid an open redirect.
✅ SonarQube Quality Gate passed — pathorsAI_pensieve0 open issues on this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
沒登入、或登入的帳號不是 workspace 成員時,文件頁只回一行純文字
forbidden,workspace 頁回 404,使用者完全不知道該怎麼辦。改了什麼
/o/[slug]/d/...)、workspace、members、settings 頁沒有權限時,一律導到新的/access?next=<原本路徑>。/access分兩種狀態:/access同時是登入後的 callback:如果選的帳號還是沒權限,會回到這頁看到原因,不會又撞一次死路。prompt: "select_account",每次登入都出現帳號選擇器;不然登出後再登入,Google 會直接用同一個帳號登回來,換不了帳號。?embed=1iframe 開時 session 過期,/access會跳出 iframe(Google 不允許在 iframe 裡登入)。導過去時會拿掉?embed=1。next只接受站內路徑(擋//host、/\host),避免 open redirect。/api/*的 JSON 403 不變。驗證
next build、tsc --noEmit通過。next start、沒登入:/o/jack-db85、/o/jack-db85/settings→ 307 到/access?next=…;/o/jack-db85/d/pathors/x?embed=1→ 302 到/access?next=%2Fo%2Fjack-db85%2Fd%2Fpathors%2Fx(embed 已拿掉);/access?next=//evil.com被當成/。