mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 13:09:46 +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 String baseUrl;
|
||||||
private boolean isPasswordUpdate;
|
private boolean isPasswordUpdate;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private int loginStep = 0;
|
||||||
|
|
||||||
|
private boolean automatedLoginAttempted = false;
|
||||||
|
|
||||||
public WebViewLoginController(String baseUrl, boolean isPasswordUpdate) {
|
public WebViewLoginController(String baseUrl, boolean isPasswordUpdate) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
this.isPasswordUpdate = isPasswordUpdate;
|
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) {
|
public WebViewLoginController(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
@ -175,6 +188,8 @@ public class WebViewLoginController extends BaseController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
loginStep++;
|
||||||
|
|
||||||
if (!basePageLoaded) {
|
if (!basePageLoaded) {
|
||||||
if (progressBar != null) {
|
if (progressBar != null) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
@ -186,6 +201,18 @@ public class WebViewLoginController extends BaseController {
|
|||||||
basePageLoaded = true;
|
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);
|
super.onPageFinished(view, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user