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

Transfer to new App User ID doesn't sync Firebase Integration #1042

Open
pxsanghyo opened this issue Apr 12, 2024 · 1 comment
Open

Transfer to new App User ID doesn't sync Firebase Integration #1042

pxsanghyo opened this issue Apr 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@pxsanghyo
Copy link

‼️ Required data ‼️

Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.

There are a lot of things that can contribute to things not working. Having a very basic understanding of your environment will help us understand your issue faster!

Environment

  • [✅] Output of flutter doctor
[✓] Flutter (Channel stable, 3.19.3, on macOS 14.4.1 23E224 darwin-x64, locale en)
    • Flutter version 3.19.3 on channel stable at /Users/sanghyo/.flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (5 weeks ago), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/sanghyo/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/sanghyo/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.71.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
  • [✅] Version of purchases-flutter
    purchases_flutter: ^7.0.0-beta.1
  • [✅] Testing device version e.g.: iOS 15.5, Android API 30, etc.
    iOS 17.4.1
  • [✅] How often the issue occurs- every one of your customers is impacted? Only in dev?
    app not in production. tested with sandbox iOS account.
  • [❌] Debug logs that reproduce the issue
  • [✅] Steps to reproduce, with a description of expected vs. actual behavior
    Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Integrate Firebase Firestore & Custom Claims
Transfer Behavior: Transfer to new App User ID

1. User A subscribes for subscription package

    A1. User A's CustomerInfo (Purchases) has PRO entitlement ✅ (Expected)
    A2. User A's IdTokenResult (FirebaseAuth) has PRO entitlement ✅ (Expected)
    A3. User A's Customer Doc (Firestore) has PRO entitlement ✅ (Expected)

2. Log out of device with User A and log in with User B and restore purchase (using same sandbox account)

    A1. User A's CustomerInfo (Purchases) has NO entitlement ✅ (Expected)
    A2. User A's IdTokenResult (FirebaseAuth) has PRO entitlement ❌ (Unexpected)
    A3. User A's Customer Doc (Firestore) has PRO entitlement ❌ (Unexpected)

    B1. User B's CustomerInfo (Purchases) has PRO entitlement ✅ (Expected)
    B2. User B's IdTokenResult (FirebaseAuth) has NO entitlement but after force getIdToken then he will have PRO entitlement ❌ (Unexpected)
    B3. User B's Customer Doc (Firestore) has PRO entitlement ✅ (Expected)

3. When the subscription ends (after 12 renewals) -- User B has the subscription

    A1. User A's CustomerInfo (Purchases) has NO entitlement ✅ (Expected)
    A2. User A's IdTokenResult (FirebaseAuth) has PRO entitlement ❌ (Unexpected)
    A3. User A's Customer Doc (Firestore) has PRO entitlement ❌ (Unexpected)

    B1. User B's CustomerInfo (Purchases) has NO entitlement ✅ (Expected)
    B2. User B's IdTokenResult (FirebaseAuth) has PRO entitlement ❌ (Unexpected)
    B3. User B's Customer Doc (Firestore) has PRO entitlement (expired) ❌ (Unexpected)

Describe the bug

With Transfer to new App User ID
I expect User A's Firebase Auth and Firestore to have entitlement removed after the subscription gets transferred to User B.

Also, I expect after User B's subscription ends, User A's and User B's entitlement in Firebase Auth and Firestore removed. Although for User A, they should have been removed on transfer to User B.

Also, for point 2.B2 the app must force getIdToken once the purchase is restored to get the correct entitlement in custom claims but this is not the case for purchasePackage call so I think this is also a bug.

Additional context

I tried force refreshing Firebase Auth user id token but User A and User B still has the entitlement in Firebase integrations (Custom Claims and Firestore Document), even after the renewal period ends.

@pxsanghyo pxsanghyo added the bug Something isn't working label Apr 12, 2024
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

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

No branches or pull requests

2 participants