Selaa lähdekoodia

Fix #295

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 vuotta sitten
vanhempi
commit
accbbdc9a7

+ 5 - 9
app/src/main/java/com/nextcloud/talk/controllers/SwitchAccountController.java

@@ -86,7 +86,7 @@ public class SwitchAccountController extends BaseController {
         public boolean onItemClick(View view, int position) {
             if (userItems.size() > position) {
                 Account account = ((AdvancedUserItem) userItems.get(position)).getAccount();
-                verifyAccount(account);
+                reauthorizeFromImport(account);
             }
 
             return true;
@@ -237,15 +237,11 @@ public class SwitchAccountController extends BaseController {
         swipeRefreshLayout.setEnabled(false);
     }
 
-    private void verifyAccount(Account account) {
+    private void reauthorizeFromImport(Account account) {
         ImportAccount importAccount = AccountUtils.getInformationFromAccount(account);
-        Bundle bundle = new Bundle();
-        bundle.putString(BundleKeys.KEY_USERNAME, importAccount.getUsername());
-        bundle.putString(BundleKeys.KEY_TOKEN, importAccount.getToken());
-        bundle.putString(BundleKeys.KEY_BASE_URL, importAccount.getBaseUrl());
-        bundle.putBoolean(BundleKeys.KEY_IS_ACCOUNT_IMPORT, true);
-        getRouter().pushController(RouterTransaction.with(new AccountVerificationController
-                (bundle)).pushChangeHandler(new HorizontalChangeHandler())
+        getRouter().pushController(RouterTransaction.with(new WebViewLoginController(importAccount.getBaseUrl(),
+                false, importAccount.getUsername(), ""))
+                .pushChangeHandler(new HorizontalChangeHandler())
                 .popChangeHandler(new HorizontalChangeHandler()));
     }
 

+ 10 - 5
app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.java

@@ -208,15 +208,20 @@ public class WebViewLoginController extends BaseController {
                     basePageLoaded = true;
                 }
 
-                if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {
+                if (!TextUtils.isEmpty(username)) {
                     if (loginStep == 1) {
                         webView.loadUrl("javascript: {document.getElementsByClassName('login')[0].click(); };");
                     } else if (!automatedLoginAttempted) {
                         automatedLoginAttempted = true;
-                        webView.loadUrl("javascript: {" +
-                                "document.getElementById('user').value = '" + username + "';" +
-                                "document.getElementById('password').value = '" + password + "';" +
-                                "document.getElementById('submit').click(); };");
+                        if (TextUtils.isEmpty(password)) {
+                            webView.loadUrl("javascript: {" +
+                                    "document.getElementById('user').value = '" + username + "'; };");
+                        } else {
+                            webView.loadUrl("javascript: {" +
+                                    "document.getElementById('user').value = '" + username + "';" +
+                                    "document.getElementById('password').value = '" + password + "';" +
+                                    "document.getElementById('submit').click(); };");
+                        }
                     }
                 }