如何在 OnReceivedHttpAuthRequest 中验证 username/password?
How do I validate a username/password in OnReceivedHttpAuthRequest?
我正在尝试存储 Windows 凭据以在 webview 中登录到 Intranet webapp。
var login = Application.Context.GetSharedPreferences("Login", FileCreationMode.Private);
string username = login.GetString("username", null);
string password = login.GetString("password", null);
if (username != null && password != null)
handler.Proceed(username, password);
但是当密码错误时它会不断尝试直到帐户被锁定。如何检查 Proceed
是否不成功,以便我可以重新提示用户输入新凭据。
这是我的建议:
int requestCount;
public override void OnReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, string host, string realm)
{
requestCount++;
if(requestCount <3)
{
handler.Proceed(username, password);
}
else
{
//show a Dialog(with two edittext for input username and password) which notice credentials failure and reprompt the user to enter in new credentials
//when you click Dialog's "Ok" reset requestCount to 0 and call "handler.Proceed(newUsername, newPassword);"
//when you click Dialog's "Cancel" call "handler.Cancel();"
}
}
问题是保存的密码不正确。
- 从无开始 username/password
- 用户输入username/password后,勾选。如果正确
保存它,如果没有重新开始。
- 后面需要username/password的时候,先去取,然后查看
- 如果它工作并记录下来,那么我们就完成了。
- 如果它不起作用清除商店并重新开始
我正在尝试存储 Windows 凭据以在 webview 中登录到 Intranet webapp。
var login = Application.Context.GetSharedPreferences("Login", FileCreationMode.Private);
string username = login.GetString("username", null);
string password = login.GetString("password", null);
if (username != null && password != null)
handler.Proceed(username, password);
但是当密码错误时它会不断尝试直到帐户被锁定。如何检查 Proceed
是否不成功,以便我可以重新提示用户输入新凭据。
这是我的建议:
int requestCount;
public override void OnReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, string host, string realm)
{
requestCount++;
if(requestCount <3)
{
handler.Proceed(username, password);
}
else
{
//show a Dialog(with two edittext for input username and password) which notice credentials failure and reprompt the user to enter in new credentials
//when you click Dialog's "Ok" reset requestCount to 0 and call "handler.Proceed(newUsername, newPassword);"
//when you click Dialog's "Cancel" call "handler.Cancel();"
}
}
问题是保存的密码不正确。
- 从无开始 username/password
- 用户输入username/password后,勾选。如果正确 保存它,如果没有重新开始。
- 后面需要username/password的时候,先去取,然后查看
- 如果它工作并记录下来,那么我们就完成了。
- 如果它不起作用清除商店并重新开始