Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: authentication on public routes #6765

Merged
merged 13 commits into from
Feb 13, 2024

Conversation

martabal
Copy link
Member

This PR aims to refactor the authentication on public routes to avoid 400 requests on shared links

Copy link

cloudflare-workers-and-pages bot commented Jan 30, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: b6b1c52
Status:⚡️  Build in progress...

View logs

@martabal martabal force-pushed the refactor/authentication-public-routes branch 2 times, most recently from 5a077e8 to 70f84c9 Compare January 30, 2024 18:43
@martabal martabal marked this pull request as ready for review January 30, 2024 20:17
web/src/lib/utils/auth.ts Outdated Show resolved Hide resolved
web/src/lib/utils/cookies.ts Outdated Show resolved Hide resolved
web/src/lib/utils/cookies.ts Outdated Show resolved Hide resolved
@martabal martabal force-pushed the refactor/authentication-public-routes branch 2 times, most recently from 60febd8 to c748d54 Compare January 30, 2024 22:24
web/src/lib/utils/auth.ts Outdated Show resolved Hide resolved
@martabal martabal force-pushed the refactor/authentication-public-routes branch 2 times, most recently from 2b53107 to 6647a57 Compare January 31, 2024 00:01
Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

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

LGTM


if (!user) {
redirect(302, AppRoute.AUTH_LOGIN);
if (options.public && !user) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you care if the user is defined or not if the route is public?

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems like you want:

  1. if public return we're done with all the checks
  2. if not user, redirect to login, this is an auth required route
  3. if admin route and not an admin, redirect to /photos

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

LGTM

@jrasm91 jrasm91 force-pushed the refactor/authentication-public-routes branch from 5a9af37 to b6b1c52 Compare February 13, 2024 01:44
@jrasm91 jrasm91 enabled auto-merge (squash) February 13, 2024 01:45
@jrasm91 jrasm91 merged commit f1e4fdf into main Feb 13, 2024
23 of 24 checks passed
@jrasm91 jrasm91 deleted the refactor/authentication-public-routes branch February 13, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants