private void OnAuthenticateCompleted(AuthenticationResultEventArgs args) { var handler = AuthenticateCompleted; if (handler != null) { handler(this, args); } }
private void OnLoginSuccess(object sender, AuthenticationResultEventArgs args) { if (!args.LoginSuccessful) { Error = "Invalid username or password.."; return; } Action handler = _loginSuccess; if (handler != null) { handler(); } }
private void ProcessLoginResponse(IAsyncResult ctx) { Execute.OnUIThread(() => { AuthenticationResultEventArgs args = new AuthenticationResultEventArgs(); try { var rqst = (HttpWebRequest)ctx.AsyncState; var response = (HttpWebResponse)rqst.EndGetResponse(ctx); if (response.StatusCode == HttpStatusCode.OK && response.Headers[HttpRequestHeader.Authorization] == "Success!") { args.LoginSuccessful = true; args.Result = "Success!"; } else { args.LoginSuccessful = false; args.Result = response.Headers[HttpRequestHeader.Authorization]; } } catch (Exception ex) { args.LoginSuccessful = true; args.Result = "Error!"; args.Exception = ex; } finally { CurrentUser.LastLoginResult = args; CurrentUser.IsLoggedIn = args.LoginSuccessful; //CurrentUser.Token OnAuthenticateCompleted(args); } }); }