Skip to content

Chore: address @todo in do-auth actions #15

@babblebey

Description

@babblebey

Leaving this here as reference for @todo

  1. make the parsedState data more predictable (order by path, redirect)

    The intention of this is to avoid unpredictability in the value of the parsedState computed from...

    const parsedState = String(Object.keys(state).map(key => key + ":" + state[key]).join("|"));

    ... the value is expected to look like path:[value]|redirect:[value], and be ordered by path first, the redirect next (in cases where redirect is present in state) in order to allow correct consumption in the github oauth callback handler

    // src/pages/api/github/oauth/callback.js
    
    const path = state.includes("path") && state.split("|")[0].split(":")[1];
    const isRedirect = state.includes("redirect") ? state.split("|")[1].split(":")[1] : false;

    ...failure to adhere to this order will cause failure; the point of initialization where this order can be inputted in the wrong order is in the login page

    // src/pages/login.astro
    
    const authUrl = getAuthUrl({
      path: searchParams.get("redirect"),
      redirect: true
    });

    ... in cases where the path isn't stated as first value on the getAuthUrl argument object before the redirect; this will cause the error.

Originally posted by @babblebey in https://github.com/babblebey/jargons.dev/pull/8#discussion_r1545383948

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions