mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Only check token for logged in users
This commit is contained in:
parent
e7f84b8aed
commit
3195f05e56
@ -1144,31 +1144,32 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
mFetchUserInfoSuccess = false;
|
||||
}
|
||||
});
|
||||
|
||||
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), mAccessToken, new FetchSiteInfo.FetchSiteInfoListener() {
|
||||
@Override
|
||||
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||
String[] version = siteInfo.getVersion().split("\\.");
|
||||
if (version.length > 0) {
|
||||
Log.d("MainActvity", "Lemmy Version: " + version[0] + "." + version[1]);
|
||||
int majorVersion = Integer.parseInt(version[0]);
|
||||
int minorVersion = Integer.parseInt(version[1]);
|
||||
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
|
||||
mRetrofit.setAccessToken(mAccessToken);
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
|
||||
checkUserToken();
|
||||
} else {
|
||||
mRetrofit.setAccessToken(null);
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, false).apply();
|
||||
if (mAccessToken != null) {
|
||||
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), mAccessToken, new FetchSiteInfo.FetchSiteInfoListener() {
|
||||
@Override
|
||||
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||
String[] version = siteInfo.getVersion().split("\\.");
|
||||
if (version.length > 0) {
|
||||
Log.d("MainActvity", "Lemmy Version: " + version[0] + "." + version[1]);
|
||||
int majorVersion = Integer.parseInt(version[0]);
|
||||
int minorVersion = Integer.parseInt(version[1]);
|
||||
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
|
||||
mRetrofit.setAccessToken(mAccessToken);
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
|
||||
checkUserToken();
|
||||
} else {
|
||||
mRetrofit.setAccessToken(null);
|
||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, false).apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchSiteInfoFailed() {
|
||||
@Override
|
||||
public void onFetchSiteInfoFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user