File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
app/src/main/java/fr/free/nrw/commons/auth Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 1919import android .support .v7 .app .AppCompatDelegate ;
2020import android .text .Editable ;
2121import android .text .TextWatcher ;
22- import android .util .Log ;
2322import android .view .MenuInflater ;
2423import android .view .MenuItem ;
2524import android .view .View ;
2827import android .widget .Button ;
2928import android .widget .EditText ;
3029import android .widget .TextView ;
31- import android .widget .Toast ;
3230
3331import java .io .IOException ;
3432
@@ -160,7 +158,10 @@ protected void onResume() {
160158 WelcomeActivity .startYourself (this );
161159 prefs .edit ().putBoolean ("firstrun" , false ).apply ();
162160 }
163- if (sessionManager .getCurrentAccount () != null ) {
161+
162+ if (sessionManager .getCurrentAccount () != null
163+ && sessionManager .isUserLoggedIn ()
164+ && sessionManager .getCachedAuthCookie () != null ) {
164165 startMainActivity ();
165166 }
166167 }
Original file line number Diff line number Diff line change @@ -61,20 +61,26 @@ public Boolean revalidateAuthToken() {
6161 }
6262
6363 public String getAuthCookie () {
64- boolean isLoggedIn = sharedPreferences .getBoolean ("isUserLoggedIn" , false );
65-
66- if (!isLoggedIn ) {
64+ if (!isUserLoggedIn ()) {
6765 Timber .e ("User is not logged in" );
6866 return null ;
6967 } else {
70- String authCookie = sharedPreferences . getString ( "getAuthCookie" , null );
68+ String authCookie = getCachedAuthCookie ( );
7169 if (authCookie == null ) {
7270 Timber .e ("Auth cookie is null even after login" );
7371 }
7472 return authCookie ;
7573 }
7674 }
7775
76+ public String getCachedAuthCookie () {
77+ return sharedPreferences .getString ("getAuthCookie" , null );
78+ }
79+
80+ public boolean isUserLoggedIn () {
81+ return sharedPreferences .getBoolean ("isUserLoggedIn" , false );
82+ }
83+
7884 public Completable clearAllAccounts () {
7985 AccountManager accountManager = AccountManager .get (context );
8086 Account [] allAccounts = accountManager .getAccountsByType (ACCOUNT_TYPE );
You can’t perform that action at this time.
0 commit comments