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

[Dart ory_kratos_client] Unable to build Update...FlowBody #290

Open
3 of 5 tasks
Nelfimov opened this issue Aug 29, 2023 · 1 comment
Open
3 of 5 tasks

[Dart ory_kratos_client] Unable to build Update...FlowBody #290

Nelfimov opened this issue Aug 29, 2023 · 1 comment
Labels
bug Something is not working.

Comments

@Nelfimov
Copy link

Preflight checklist

Ory Network Project

No response

Describe the bug

updateRegistrationFlowBody requires

  • flow - Flow ID as string
  • updateRegistrationFlowBody - builder function to create flow body

Unfortunately creating UpdateRegistrationFlowBody provides only oneOf, whereas auto-generated docs describe the required for me arguments like method, traits and so on.

I have tried creating flow body with following snippets with no success:

1
  final body = UpdateRegistrationFlowBody((b) => b
    ..oneOf = UpdateRegistrationFlowWithPasswordMethod((p) => p
      ..password = password
      ..traits = Traits((t) => t..email = email)));

  kratosClient
      .updateRegistrationFlow(
        flow: registrationFlow.id,
        updateRegistrationFlowBody: body,
      )
2
final body = UpdateRegistrationFlowBody((b) => b
  ..oneOf = OneOf<UpdateRegistrationFlowWithPasswordMethod>.of(
    UpdateRegistrationFlowWithPasswordMethod(
      (b) => b..password = password
    )
  )
);

This package however provides needed function to create flow body - SubmitSelfServiceRegistrationFlowBody

Reproducing the bug

  1. Create RegistrationFlow
  2. Try to update its body

Relevant log output

No response

Relevant configuration

No response

Version

0.13.1

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

None

Additional Context

No response

@Nelfimov Nelfimov added the bug Something is not working. label Aug 29, 2023
@MickaelBenasse
Copy link

@Nelfimov Hi, I finally found a solution after really a long time of digging. I had the same problem as you.
So, first of all, we missing a lot of documentation on the dart client. You will need two package in order to have it working: OneOf and built_value.

Then I had it working doing so (this is maybe not the best way of doing it but since it was a error and try attempt, I didn't wanted to loose more time having it working):

final Response<SuccessfulNativeRegistration> response;
final JsonObject jsonObject = JsonObject(registrationModel.toJson());

    final UpdateRegistrationFlowBody registrationFlowBody =
        UpdateRegistrationFlowBody(
      (UpdateRegistrationFlowBodyBuilder flow) => flow
        ..oneOf = OneOf.fromValue1(
          value: UpdateRegistrationFlowWithPasswordMethod(
            (UpdateRegistrationFlowWithPasswordMethodBuilder builder) => builder
              ..csrfToken = ''
              ..traits = jsonObject
              ..method = 'password'
              ..password = registrationModel.password,
          ),
        ),
    );

      response = await _oryFrontEnd.updateRegistrationFlow(
        flow: url,
        updateRegistrationFlowBody: registrationFlowBody,
      );

Hope it will help you in future development !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

2 participants