Fix authentication with openid

This commit is contained in:
Thomas 2022-05-10 10:19:45 +02:00
parent bd8e2a50d9
commit af53071b08
3 changed files with 13 additions and 17 deletions

View File

@ -19,6 +19,7 @@ import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.updateCredentia
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
@ -35,8 +36,10 @@ import androidx.appcompat.app.AlertDialog;
import java.net.URL;
import java.util.regex.Matcher;
import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.entities.AcadInstances;
import app.fedilab.fedilabtube.client.entities.Error;
import app.fedilab.fedilabtube.client.entities.OauthParams;
import app.fedilab.fedilabtube.client.entities.Token;
@ -123,6 +126,15 @@ public class WebviewConnectActivity extends BaseActivity {
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
//Avoid to load first page for academic instances & openid
if (!BuildConfig.full_instances && url.contains("/client")) {
view.stopLoading();
}
}
@Override
public void onPageFinished(WebView view, String url) {
Matcher matcher = Helper.redirectPattern.matcher(url);
@ -145,6 +157,7 @@ public class WebviewConnectActivity extends BaseActivity {
try {
token = new RetrofitPeertubeAPI(WebviewConnectActivity.this, instance, null).manageToken(oauthParams);
} catch (Error error) {
error.printStackTrace();
Error.displayError(WebviewConnectActivity.this, error);
}
if (token != null) {

View File

@ -14,23 +14,10 @@ package app.fedilab.fedilabtube.helper;
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import static app.fedilab.fedilabtube.helper.Helper.TAG;
import android.util.Log;
import androidx.annotation.IdRes;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ContextThemeWrapper;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.LinkedHashMap;
import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.R;
public class HelperAcadInstance {

View File

@ -1,12 +1,8 @@
package app.fedilab.fedilabtube.helper;
import static app.fedilab.fedilabtube.helper.Helper.TAG;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Locale;