Skip to content

Change username auth's login() signature #2598

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

Merged
merged 3 commits into from
Apr 9, 2025
Merged

Conversation

cprecioso
Copy link
Member

@cprecioso cprecioso commented Apr 2, 2025

Description

BREAKING CHANGE

In email auth, wasp/client/auth imports login and signup, each accept a single argument like login({email, password}). In username auth signup also accepts a single argument signup({ username, password}). But, login requires two different arguments like login(username, password).

This PR updates it so it turns into login({username, password}).

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

Update Waspc ChangeLog and version if needed

If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

Update example apps if needed

If you did code changes and added a new feature or modified an existing feature, make sure you satisfy the following:

  1. I updated waspc/examples/todoApp as needed (updated modified feature or added new feature) and manually checked it works correctly.
  2. I updated waspc/headless-test/examples/todoApp and its e2e tests as needed (updated modified feature and its tests or added new feature and new tests for it).
  3. Updated waspello

@Martinsos Martinsos requested a review from infomiho April 2, 2025 12:02
@Martinsos
Copy link
Member

Whoops I by half-accident requested @infomiho here as a rewviewr but forgot it is still a draft, so probably don't do anything yet and wait for @cprecioso to give the green light! My bad.

@Martinsos Martinsos added the auth label Apr 2, 2025
Base automatically changed from 1438-email-auth-docs-dont-explain-how-to-use-signup-and-login-actions to main April 4, 2025 16:09
@cprecioso cprecioso force-pushed the cprecioso/push-qvtrrkynxqvz branch from bbcf1be to 70cdf3c Compare April 7, 2025 13:22
@cprecioso cprecioso changed the title WIP: Change username auth's login() signature Change username auth's login() signature Apr 7, 2025
@cprecioso cprecioso marked this pull request as ready for review April 7, 2025 14:26
@cprecioso
Copy link
Member Author

@infomiho ready

Copy link
Contributor

@infomiho infomiho left a comment

Choose a reason for hiding this comment

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

This is great! I've left some refactor ideas just to clean up this part of the code base a tiny bit.

Also, let's update the Changelog with a "Next" version (I think this will go out with 0.17.0 but let's just keep it Next for now)

@@ -2,10 +2,9 @@
import { api, handleApiError } from 'wasp/client/api'
import { initSession } from './helpers/user'

export default async function login(username: string, password: string): Promise<void> {
export default async function login(userFields: { username: string, password: string }): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make this object name same for the username & password actions as we have for the email actions (data)? This is out of scope of this PR somewhat, but let's do some cleanup while we are here :)

@@ -2,10 +2,9 @@
import { api, handleApiError } from 'wasp/client/api'
Copy link
Contributor

Choose a reason for hiding this comment

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

One other refactor I'd suggest we do while we are here, is that we move the username related actions (they are quite old code) to a similar folder structure as we have for email e.g. wasp/auth/username/index.ts + wasp/auth/username/actions/login.ts + wasp/auth/username/actions/signup.ts.

You'll need to edit some Haskell code as well, but I think it's a good learning opportunity to get to know the codebase a bit more: https://github.com/wasp-lang/wasp/blob/main/waspc/src/Wasp/Generator/SdkGenerator/Auth/LocalAuthG.hs#L30

Copy link
Member Author

@cprecioso cprecioso Apr 8, 2025

Choose a reason for hiding this comment

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

Do you mind if we do that in another PR? I'll probably need a back and forth there and it's out of scope for the current PR. Got started at #2644

@cprecioso
Copy link
Member Author

@infomiho ready

Copy link
Contributor

@infomiho infomiho left a comment

Choose a reason for hiding this comment

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

Let's merge this after #2644

@cprecioso
Copy link
Member Author

Let's merge this after #2644

I already have that one on top of this one, so it's way easier to keep it like this 🙏 any specific reason to change the order?

@infomiho
Copy link
Contributor

infomiho commented Apr 9, 2025

I misunderstood the order of branches, yeah, let's merge this and then the other PR 👍

@cprecioso cprecioso merged commit d6f54c2 into main Apr 9, 2025
6 checks passed
@cprecioso cprecioso deleted the cprecioso/push-qvtrrkynxqvz branch April 9, 2025 12:41
cprecioso added a commit that referenced this pull request Apr 10, 2025
@cprecioso cprecioso mentioned this pull request Apr 10, 2025
4 tasks
cprecioso added a commit that referenced this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants