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

Fix converter getting called twice if using an authenticator with a JsonConverter on the request #324

Merged
merged 4 commits into from Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion chopper/lib/src/authenticator.dart
Expand Up @@ -5,5 +5,6 @@ import 'package:chopper/chopper.dart';
/// This method should return a [Request] that includes credentials to satisfy an authentication challenge received in
/// [response]. It should return `null` if the challenge cannot be satisfied.
abstract class Authenticator {
FutureOr<Request?> authenticate(Request request, Response response);
FutureOr<Request?> authenticate(Request request, Response response,
[Request? originalRequest]);
}
2 changes: 1 addition & 1 deletion chopper/lib/src/base.dart
Expand Up @@ -311,7 +311,7 @@ class ChopperClient {
dynamic res = Response(response, response.body);

if (authenticator != null) {
var updatedRequest = await authenticator!.authenticate(req, res);
var updatedRequest = await authenticator!.authenticate(req, res, request);

if (updatedRequest != null) {
res = await send<BodyType, InnerType>(
Expand Down