From fde33dbc3e737b7faa1e5e9b5dd9119cd0acca52 Mon Sep 17 00:00:00 2001 From: Unpublished Date: Wed, 27 Nov 2019 18:45:39 +0100 Subject: [PATCH] Allow login if api is restricted --- .../mian/gitnex/activities/LoginActivity.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java index f1006e77..7a4e8a07 100644 --- a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java @@ -396,12 +396,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList case SUPPORTED_LATEST: case SUPPORTED_OLD: case DEVELOPMENT: - if(loginType == 1) { - letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP); - } - else if(loginType == 2) { // token - letTheUserInViaToken(instanceUrl, loginToken_); - } + login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken_); return; case UNSUPPORTED_OLD: @@ -424,12 +419,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); - if(loginType == 1) { - letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP); - } - else if(loginType == 2) { // token - letTheUserInViaToken(instanceUrl, loginToken_); - } + login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken_); } }); @@ -445,7 +435,18 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList } } + else if (responseVersion.code() == 403) { + login(loginType, instanceUrl, loginUid, loginPass, loginOTP, loginToken_); + } + } + private void login(int loginType, String instanceUrl, String loginUid, String loginPass, int loginOTP, String loginToken_) { + if (loginType == 1) { + letTheUserIn(instanceUrl, loginUid, loginPass, loginOTP); + } + else if (loginType == 2) { // token + letTheUserInViaToken(instanceUrl, loginToken_); + } } @Override