mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 12:39:58 +01:00
Added initial support for automated login
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
61b6e25c47
commit
d74d8e3aef
@ -107,11 +107,24 @@ public class WebViewLoginController extends BaseController {
|
||||
private String baseUrl;
|
||||
private boolean isPasswordUpdate;
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
private int loginStep = 0;
|
||||
|
||||
private boolean automatedLoginAttempted = false;
|
||||
|
||||
public WebViewLoginController(String baseUrl, boolean isPasswordUpdate) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.isPasswordUpdate = isPasswordUpdate;
|
||||
}
|
||||
|
||||
public WebViewLoginController(String baseUrl, boolean isPasswordUpdate, String username, String password) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.isPasswordUpdate = isPasswordUpdate;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public WebViewLoginController(Bundle args) {
|
||||
super(args);
|
||||
}
|
||||
@ -175,6 +188,8 @@ public class WebViewLoginController extends BaseController {
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
loginStep++;
|
||||
|
||||
if (!basePageLoaded) {
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
@ -186,6 +201,18 @@ public class WebViewLoginController extends BaseController {
|
||||
basePageLoaded = true;
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {
|
||||
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(); };");
|
||||
}
|
||||
}
|
||||
|
||||
super.onPageFinished(view, url);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user