Skip to content

Commit

Permalink
Merge pull request #117 from aboutyou/feature/sign-in-with-apple/fix-…
Browse files Browse the repository at this point in the history
…android-deeplink-parsing

Fix android deeplink parsing for user properties only with an email
  • Loading branch information
HenriBeck authored Jul 26, 2020
2 parents 0c1c4b8 + f0833bc commit ed47776
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/sign_in_with_apple/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.5.2

- Fix a bug where the authentication would crash on Android if only the `AppleIDAuthorizationScopes.email` was requested ([#117](https://github.com/aboutyou/dart_packages/pull/117))

## 2.5.1

- Fix security deeplink issue which allowed to crash Flutter apps which have the `signinwithapple` plugin installed on Android ([#103](https://github.com/aboutyou/dart_packages/pull/103))
Expand Down
2 changes: 1 addition & 1 deletion packages/sign_in_with_apple/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.5.1"
version: "2.5.2"
sky_engine:
dependency: transitive
description: flutter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,13 @@ AuthorizationCredentialAppleID parseAuthorizationCredentialAppleIDFromDeeplink(
final user = deeplink.queryParameters.containsKey('user')
? json.decode(deeplink.queryParameters['user']) as Map<String, dynamic>
: null;
final name = user != null ? user['name'] as Map<String, dynamic> : null;

return AuthorizationCredentialAppleID(
authorizationCode: deeplink.queryParameters['code'],
email: user != null ? user['email'] as String : null,
givenName: user != null ? user['name']['firstName'] as String : null,
familyName: user != null ? user['name']['lastName'] as String : null,
givenName: name != null ? name['firstName'] as String : null,
familyName: name != null ? name['lastName'] as String : null,
userIdentifier: null,
identityToken: deeplink.queryParameters['id_token'],
state: deeplink.queryParameters['state'],
Expand Down
2 changes: 1 addition & 1 deletion packages/sign_in_with_apple/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sign_in_with_apple
description: Flutter bridge to initiate Sign in with Apple (on iOS, macOS, and Android). Includes support for keychain entries as well as signing in with an Apple ID.
version: 2.5.1
version: 2.5.2
homepage: https://github.com/aboutyou/dart_packages/tree/master/packages/sign_in_with_apple
repository: https://github.com/aboutyou/dart_packages

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,28 @@ void main() {
'4rtppgbhgb@privaterelay.appleid.com',
);
});

test(
'parseAuthorizationCredentialAppleIDFromDeeplink: With user but only email',
() async {
final deeplink = Uri.parse(
'signinwithapple://callback?code=c7253d404c180400eaa4691aa9c8c07ff.0.nrqtw.OALT9--SjOoLRti_wvrF5Q&user=%7B%22email%22%3A%224rtppgbhgb%40privaterelay.appleid.com%22%7D',
);

final parsed = parseAuthorizationCredentialAppleIDFromDeeplink(deeplink);

expect(
parsed.authorizationCode,
'c7253d404c180400eaa4691aa9c8c07ff.0.nrqtw.OALT9--SjOoLRti_wvrF5Q',
);

expect(parsed.givenName, isNull);
expect(parsed.familyName, isNull);

expect(
parsed.email,
'4rtppgbhgb@privaterelay.appleid.com',
);
},
);
}

0 comments on commit ed47776

Please sign in to comment.