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

Process CentralAuth redirects on new lexeme as TempUser #640

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

codders
Copy link
Contributor

@codders codders commented Feb 13, 2024

With T357024, the API will return a URL initialized by CentralAuth when a TempUser tries to create a new lexeme. We need to redirect to this URL instead of the new lexeme (the URL will then redirect to the new lexeme once it’s finished setting up the temporary account).

Bug: T357152

Copy link
Member

@lucaswerkmeister lucaswerkmeister left a comment

Choose a reason for hiding this comment

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

I feel like we should turn the WikiRouter service into something else, because this basically takes the “routing” out of it – we still need it to be configurable (because we don’t want window.location to be assigned in the tests), but I wouldn’t call it a “router” anymore. Perhaps it’s a “navigator” now? (Though the Navigator API doesn’t include “redirect”-like functionality, so maybe that would be confusing.)

In theory we could also keep the “routing” in the service – e.g., the lexeme creator can return either a URL or a string, and if it’s a string then it represents a title and the router is still responsible for turning that into a URL – but that feels silly to me tbh. Having the lexeme creator always return a URL is cleaner, even if that means that it sometimes has an extra responsibility (turning a title into a URL).

We could also extract the changes to the router service into a separate commit (with or without a separate pull request) – first move the “routing” into the lexeme creator (but always using MwUtilGetUrl), then use the redirect URL in the response if it exists.

@codders
Copy link
Contributor Author

codders commented Feb 15, 2024

What's the advantage for you of having the changes in a separate commit? I don't imagine that anyone will be interested in the intermediate state, and at this point its just extra work to turn the one commit into two individually meaningful and functional commits.

@codders codders force-pushed the feat/redirect-after-new-lexeme/20240213 branch 2 times, most recently from fec81a2 to 2cfa3dd Compare February 15, 2024 09:52
@codders codders changed the title [WIP] Process CentralAuth redirects on new lexeme as TempUser Process CentralAuth redirects on new lexeme as TempUser Feb 15, 2024
@codders
Copy link
Contributor Author

codders commented Feb 15, 2024

I've updated this now to use the correct fields from the API response. In my local testing the redirect is functioning, so from my side this is now no longer WIP - it should be good to go (though it depends on those other changes).

src/data-access/LexemeCreator.ts Show resolved Hide resolved
src/data-access/MwApiLexemeCreator.ts Outdated Show resolved Hide resolved
src/data-access/MwApiLexemeCreator.ts Outdated Show resolved Hide resolved
tests/unit/data-access/MwApiLexemeCreator.test.ts Outdated Show resolved Hide resolved
@lucaswerkmeister
Copy link
Member

What's the advantage for you of having the changes in a separate commit? I don't imagine that anyone will be interested in the intermediate state, and at this point its just extra work to turn the one commit into two individually meaningful and functional commits.

It makes the change easier to review, and at least for me, easier to work on as well; I start to get nervous if too many things are happening at once in a change ^^ (e.g. in the redirect/merge change I’m starting to lose track of what parts are done and what still needs doing)

@codders codders force-pushed the feat/redirect-after-new-lexeme/20240213 branch 2 times, most recently from 399a6b4 to 50685db Compare February 20, 2024 08:03
@codders
Copy link
Contributor Author

codders commented Feb 20, 2024

Okay. I split that into two commits. Can also make that two PRs if you prefer.

In preparation for changes required by T357024, move the
responsibility for generating the Wiki URL out of WikiRouter and
into the LexemeCreator. This way, the LexemeCreator always returns
an absolute URL (which in future may also be a redirect to another
site).

Bug: T357152
With T357024, the API will return a URL initialized by CentralAuth
when a TempUser tries to create a new lexeme. We need to redirect
to this URL instead of the new lexeme (the URL will then redirect
to the new lexeme once it’s finished setting up the temporary
account).

Bug: T357152
@codders codders force-pushed the feat/redirect-after-new-lexeme/20240213 branch from 50685db to cce2953 Compare February 20, 2024 08:10
Copy link
Member

@lucaswerkmeister lucaswerkmeister left a comment

Choose a reason for hiding this comment

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

Seems to work fine locally, thanks!

@codders codders merged commit 5846abd into main Feb 20, 2024
2 checks passed
@codders codders deleted the feat/redirect-after-new-lexeme/20240213 branch February 20, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants