-
Notifications
You must be signed in to change notification settings - Fork 136
[REST API] Check user role #8156
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
Conversation
88bcf31 to
eda59a3
Compare
|
You can test the changes on this Pull Request by downloading an installable build, or scanning this QR code: |
Codecov ReportBase: 42.92% // Head: 42.91% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## trunk #8156 +/- ##
============================================
- Coverage 42.92% 42.91% -0.02%
+ Complexity 3484 3483 -1
============================================
Files 686 686
Lines 37340 37344 +4
Branches 4960 4964 +4
============================================
- Hits 16030 16026 -4
- Misses 19864 19873 +9
+ Partials 1446 1445 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
9c9fd4c to
7dad4d1
Compare
|
Found 1 violations: The PR caused the following dependency changes:expand
-+--- org.wordpress:fluxc:2.10.0
-| +--- org.wordpress:wellsql:1.7.0
-| | \--- org.wordpress.wellsql:wellsql-annotations:1.7.0
-| +--- org.wordpress.fluxc:fluxc-annotations:2.10.0
-| +--- org.greenrobot:eventbus:3.3.1 (*)
-| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
-| +--- com.android.volley:volley:1.1.1 -> 1.2.0
-| +--- androidx.paging:paging-runtime:2.1.2
-| | +--- androidx.paging:paging-common:2.1.2
-| | | +--- androidx.annotation:annotation:1.0.0 -> 1.5.0 (*)
-| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
-| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.5.1 (*)
-| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
-| +--- com.goterl:lazysodium-android:5.0.2
-| +--- net.java.dev.jna:jna:5.5.0
-| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.7.20 (*)
-| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10 -> 1.7.20
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 (*)
-| +--- androidx.appcompat:appcompat:1.0.2 -> 1.5.0 (*)
-| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
-| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3
-| | \--- androidx.annotation:annotation:1.2.0 -> 1.5.0 (*)
-| +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
-| | +--- androidx.annotation:annotation:1.1.0 -> 1.5.0 (*)
-| | +--- com.google.crypto.tink:tink-android:1.5.0
-| | \--- androidx.collection:collection:1.1.0 -> 1.2.0 (*)
-| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
-| | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.7.20 (*)
-| +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
-| +--- org.apache.commons:commons-text:1.10.0 (*)
-| +--- androidx.room:room-runtime:2.4.2 (*)
-| +--- androidx.room:room-ktx:2.4.2
-| | +--- androidx.room:room-common:2.4.2 (*)
-| | +--- androidx.room:room-runtime:2.4.2 (*)
-| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 -> 1.7.20 (*)
-| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2 -> 1.6.4 (*)
-| +--- com.google.dagger:dagger:2.42
-| | \--- javax.inject:javax.inject:1
-| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
-| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
++--- org.wordpress:fluxc:trunk-463c753ae48797fd0543f237f668b322345eb69b
+| +--- org.wordpress:wellsql:1.7.0
+| | \--- org.wordpress.wellsql:wellsql-annotations:1.7.0
+| +--- org.wordpress.fluxc:fluxc-annotations:trunk-463c753ae48797fd0543f237f668b322345eb69b
+| +--- org.greenrobot:eventbus:3.3.1 (*)
+| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
+| +--- com.android.volley:volley:1.1.1 -> 1.2.0
+| +--- androidx.paging:paging-runtime:2.1.2
+| | +--- androidx.paging:paging-common:2.1.2
+| | | +--- androidx.annotation:annotation:1.0.0 -> 1.5.0 (*)
+| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
+| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.5.1 (*)
+| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
+| +--- com.goterl:lazysodium-android:5.0.2
+| +--- net.java.dev.jna:jna:5.5.0
+| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.7.20 (*)
+| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10 -> 1.7.20
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 (*)
+| +--- androidx.appcompat:appcompat:1.0.2 -> 1.5.0 (*)
+| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
+| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3
+| | \--- androidx.annotation:annotation:1.2.0 -> 1.5.0 (*)
+| +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
+| | +--- androidx.annotation:annotation:1.1.0 -> 1.5.0 (*)
+| | +--- com.google.crypto.tink:tink-android:1.5.0
+| | \--- androidx.collection:collection:1.1.0 -> 1.2.0 (*)
+| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
+| | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.7.20 (*)
+| +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
+| +--- org.apache.commons:commons-text:1.10.0 (*)
+| +--- androidx.room:room-runtime:2.4.2 (*)
+| +--- androidx.room:room-ktx:2.4.2
+| | +--- androidx.room:room-common:2.4.2 (*)
+| | +--- androidx.room:room-runtime:2.4.2 (*)
+| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 -> 1.7.20 (*)
+| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2 -> 1.6.4 (*)
+| +--- com.google.dagger:dagger:2.42
+| | \--- javax.inject:javax.inject:1
+| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
+| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
-\--- org.wordpress.fluxc.plugins:woocommerce:2.10.0
- +--- org.wordpress:wellsql:1.7.0 (*)
- +--- org.wordpress.fluxc:fluxc-annotations:2.10.0
- +--- androidx.room:room-ktx:2.4.2 (*)
- +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.7.20 (*)
- +--- org.wordpress:fluxc:2.10.0 (*)
- +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
- +--- com.google.dagger:dagger:2.42 (*)
- +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
- +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
- \--- androidx.room:room-runtime:2.4.2 (*)
+\--- org.wordpress.fluxc.plugins:woocommerce:trunk-463c753ae48797fd0543f237f668b322345eb69b
+ +--- org.wordpress:wellsql:1.7.0 (*)
+ +--- org.wordpress.fluxc:fluxc-annotations:trunk-463c753ae48797fd0543f237f668b322345eb69b
+ +--- androidx.room:room-ktx:2.4.2 (*)
+ +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.7.20 (*)
+ +--- org.wordpress:fluxc:trunk-463c753ae48797fd0543f237f668b322345eb69b (*)
+ +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
+ +--- com.google.dagger:dagger:2.42 (*)
+ +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
+ +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
+ \--- androidx.room:room-runtime:2.4.2 (*)
Please review and act accordingly
|
Generated by 🚫 dangerJS |
|
Hey @hichamboushaba. Changes look good! But I noticed an issue when testing this scenario:
On app startup the app won't show the user role error screen. At least it won't show it the first time. I have to kill it twice and reopen it again to see the error. Check the screen recording: UserRoleUpdate.mp4When I reopen the app for the first time after switching user role, I see several expected 403 errors (which should At first, I thought it was a problem with the backend taking some time to update the user role, but I could reproduce this consistently, leaving plenty of time for the backend to update the user role (which has been very fast in all my test). Feels like some event from the eventBus is not triggered. Can you reproduce this? I'm testing on an emulator API 30 (I don't think is API related though) |
|
Thanks @JorgeMucientes for the review.
This part has been there for WordPress.com login too, the only change I did is remove the |
|
Hey @hichamboushaba sorry for generating unnecessary noise in the PR. The bug is unrelated to the code changes. So, I won't block the PR for this. Just wanted to highlight that one of the scenarios described in the PR was not working as expected. The reason is a long-standing bug that I've described in this new issue #8178. Will take a look at it and see if there's a straightforward way to fix it. |
Oh, no worries, it's good actually you caught a bug, the bug is clear, and it seems a race condition is what's needed to either have it occurring or not, that's why it didn't happen for me while it happened for you, I have an idea for a quick fix, unless you already started working on a fix yourself. |
|
Please go ahead with the quick fix @hichamboushaba! I haven't started working on it. Feel free to assign the issue #8178 to yourself 🙏🏼 |
Part of: #8110
Description
This PR adds user role fetching logic during the site credentials login.
While working on it, I found out that the Woo detection logic we have only works for users who have a valid user role, which prevents showing the correct error message.
So I updated the logic in wordpress-mobile/WordPress-FluxC-Android#2628, please check it before this PR.
Testing instructions
Login
App Startup
Images/gif
device-2023-01-10-173546.mp4
RELEASE-NOTES.txtif necessary.