-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat/Logout #204
Feat/Logout #204
Conversation
# Conflicts: # app/src/androidTest/java/com/android/streetworkapp/end2end/End2EndGeneral.kt # app/src/androidTest/java/com/android/streetworkapp/end2end/End2EndParks.kt # app/src/main/java/com/android/streetworkapp/MainActivity.kt
# Conflicts: # app/src/main/java/com/android/streetworkapp/MainActivity.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clear code ! But there's probably a problem when the user and delog something retains with which account I previously logged. And when I relog it logs directly with the previous account without offering me a choice.
preferencesViewModel.setUid("") | ||
preferencesViewModel.setName("") | ||
preferencesViewModel.setScore(0) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement: The data is removed inside the PreferencesViewModel, but when I try to re-login using the Google button, I am automatically logged in with my previous account.
After some research, I found that the Google access token needs to be revoked to fully log out the user.
This can be done using the following method:
authService.revokeAccess()
I may have done something wrong, but it's strange that I can't choose which google account to log in with. What do you think ?
For more clarity I did a small demo:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch and thanks for the video, it helped me understand the problem. In fact, the signout function of the GoogleAuthService
class didn't take care of properly resetting the client, so it wasn't properly disconnected and therefore it wasn't possible to choose a Google account to log in. I've made the changes.
I'll let you test if it works on your side. Let me know if you have any other questions or suggestions.
Quality Gate failedFailed conditions |
Yes, it works now. Thank you for adding this important addon. |
Summary
This PR implements the ability to logout from an account on the application. This involves logging out of the Google Auth Service, clearing users from the user viewmodel and clearing preferences parameters.
In order to implement this feature, it was necessary to implement a function enabling a user to be set in the
_user
value of the user viewmodel.The initialization of the Google Auth Service was moved to the main activity to enable its use in both the SignIn and Settings features. Additionally, the Google Auth Service class was refactored to improve usability across the project. These updates also pave the way for implementing account deletion functionality #171.
Changes
SetUser
function inUserViewModel.kt
.MainActivity.kt
.GoogleAuthService
class.Settings.kt
.Tests
SetUser
test function inUserViewModelTest.kt
.SettingsTest.kt
.Please fully test this feature with your device / emulator to make sure it works properly.