Issue
I'm trying to store Windows credentials to login to an intranet webapp in a webview.
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);
But when the password is wrong it just keeps trying until the account is locked out. How do I check that the Proceed was unsuccessful so I can reprompt the user to enter in new credentials.
Solution
This is my suggestion:
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();"
}
}
Answered By - Leo Zhu - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.