Always verify sessions before login
Also avoid auto-login if saved account is anonymous and invalid as this results in fetching new account every time app is restarted as long as the validation fails resulting in rate-limiting. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -41,5 +41,6 @@ sealed class AuthState {
|
||||
object SignedOut : AuthState()
|
||||
object Valid : AuthState()
|
||||
object Fetching: AuthState()
|
||||
object InValid: AuthState()
|
||||
data class Status(val status: String?) : AuthState()
|
||||
}
|
||||
@@ -91,7 +91,11 @@ class AccountActivity : BaseActivity() {
|
||||
updateStatus(getString(R.string.requesting_new_session))
|
||||
}
|
||||
AuthState.Valid -> {
|
||||
updateContents()
|
||||
}
|
||||
|
||||
AuthState.InValid -> {
|
||||
updateStatus(getString(R.string.failed_validating_account))
|
||||
}
|
||||
|
||||
AuthState.Available -> {
|
||||
@@ -105,7 +109,7 @@ class AccountActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
AuthState.SignedIn -> {
|
||||
updateContents()
|
||||
VM.observe()
|
||||
}
|
||||
|
||||
AuthState.SignedOut -> {
|
||||
|
||||
@@ -102,6 +102,11 @@ class SplashActivity : BaseActivity() {
|
||||
moveToContent()
|
||||
}
|
||||
|
||||
AuthState.InValid -> {
|
||||
updateStatus(getString(R.string.failed_validating_account))
|
||||
updateActionLayout(true)
|
||||
}
|
||||
|
||||
AuthState.Available -> {
|
||||
updateStatus(getString(R.string.session_verifying))
|
||||
updateActionLayout(false)
|
||||
@@ -113,7 +118,7 @@ class SplashActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
AuthState.SignedIn -> {
|
||||
moveToContent()
|
||||
VM.observe()
|
||||
}
|
||||
|
||||
AuthState.SignedOut -> {
|
||||
|
||||
@@ -215,7 +215,7 @@ class AuthViewModel(application: Application) : BaseAndroidViewModel(application
|
||||
buildGoogleAuthData(email, aasToken)
|
||||
}
|
||||
AccountType.ANONYMOUS -> {
|
||||
buildAnonymousAuthData()
|
||||
liveData.postValue(AuthState.InValid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/margin_small"
|
||||
android:layout_marginHorizontal="@dimen/margin_large"
|
||||
android:layout_marginVertical="@dimen/margin_small"
|
||||
android:maxLines="2"
|
||||
android:textAlignment="center"
|
||||
tools:text="Status" />
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -64,6 +64,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/txt_title"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginHorizontal="@dimen/margin_large"
|
||||
android:maxLines="2"
|
||||
android:textAlignment="center"
|
||||
tools:text="Sign in first" />
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -364,4 +364,5 @@
|
||||
<string name="checking_for_updates">Checking for updates</string>
|
||||
<string name="pref_updates_check">Automated updates check</string>
|
||||
<string name="pref_updates_check_desc">Automatically check & notify for new app updates periodically</string>
|
||||
<string name="failed_validating_account">Failed to validate account, might be rate-limited.\nPlease login again!</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user