Skip to content

Redirect unauthenticated protected memo access to sign in#5738

Merged
memoclaw merged 3 commits intousememos:mainfrom
darkestni:codex/memos-protected-memo-auth-redirect
Mar 20, 2026
Merged

Redirect unauthenticated protected memo access to sign in#5738
memoclaw merged 3 commits intousememos:mainfrom
darkestni:codex/memos-protected-memo-auth-redirect

Conversation

@darkestni
Copy link
Copy Markdown
Contributor

Resolves #5644

Summary

When an anonymous user opens a protected or private memo link, Memos currently sends them to a 403 page. This is confusing because the next useful action is usually to sign in.

This change redirects unauthenticated users to the sign-in page instead, shows a short explanation, preserves the original memo URL, and returns them to that memo after sign-in or sign-up.

Changes

  • Memo detail page now distinguishes between unauthenticated, permission denied, and not found errors.
  • Added auth redirect helpers for safe redirect targets and auth reasons.
  • Sign-in page now reads and preserves redirect targets.
  • Password sign-in now returns users to the original page after authentication.
  • Sign-up flow also preserves the original target and returns there after registration.

Behavior

  • Unauthenticated access to protected/private memo:
    • Redirect to sign-in
    • Show a short message explaining the memo is not public
    • Return to the memo after successful sign-in/sign-up
  • Authenticated but unauthorized access:
    • Keep existing 403 behavior
  • Missing memo:
    • Go to 404

Validation

  • corepack pnpm lint
  • corepack pnpm build

@darkestni darkestni requested a review from a team as a code owner March 19, 2026 03:47
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0159fc3bb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@boojack
Copy link
Copy Markdown
Member

boojack commented Mar 19, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

@memoclaw memoclaw left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! A few issues need to be addressed before this can be merged:

Missing i18n — "This memo is not public. Sign in to continue." is hardcoded English in both SignIn.tsx and SignUp.tsx. All user-facing strings should go through useTranslate() / t() with a corresponding translation key added to the i18n resource files.

Incorrect fallback route for unhandled errors — In MemoDetail.tsx, any ConnectError that isn't Unauthenticated, PermissionDenied, or NotFound (e.g. Code.Internal, Code.DeadlineExceeded) silently navigates to /404. A server error is not a not-found. Consider keeping the user on the current page (the toast is sufficient) or routing to a generic error page.

Hardcoded /auth/signup pathSignIn.tsx builds the sign-up link with a string literal /auth/signup instead of ${ROUTES.AUTH}/signup. SignUp.tsx already uses ROUTES.AUTH correctly — please keep it consistent.

Please address these before re-requesting review.

@darkestni
Copy link
Copy Markdown
Contributor Author

Thanks for the review — I addressed the requested changes in 4c67e482:

  • moved the protected memo notice into i18n resources and used t() in both auth pages
  • stopped routing unexpected MemoDetail errors to /404 and kept them as toast-only errors
  • replaced the hardcoded sign-up path in SignIn.tsx with ${ROUTES.AUTH}/signup

I also localized the fallback memo load error message while touching that code path.

Validation run:

  • corepack pnpm lint
  • corepack pnpm build

@darkestni darkestni force-pushed the codex/memos-protected-memo-auth-redirect branch from 4c67e48 to e6d7d1a Compare March 20, 2026 06:38
@darkestni darkestni requested a review from memoclaw March 20, 2026 07:09
Copy link
Copy Markdown
Contributor

@memoclaw memoclaw left a comment

Choose a reason for hiding this comment

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

Logic is sound and security handling is correct. Merging and will follow up with missing i18n fallbacks for remaining locales.

@memoclaw memoclaw merged commit 7601708 into usememos:main Mar 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redirect to login screen when accessing protected or private memo

3 participants