Example #1
0
        public static void Login(SessionCommand sessionCommand, string username, string password,
                                 OnLoginSuccessAction onLoginSuccess, OnLoginFailedAction onLoginFailed)
        {
            var formData = new Dictionary <string, string>();

            formData.Add("username", username);
            formData.Add("password", password);

            DoPostRequest(formData, "account&process=login",
                          (IWebRequest result) => {
                var apiResult = new ApiResult <ChunkDataJsonObject>(result.Json);
                if (apiResult.IsError)
                {
                    onLoginFailed(sessionCommand, apiResult);
                }
                else
                {
                    var user   = apiResult.CurrentUser;
                    _sessionId = apiResult.SessionId;
                    _user      = user;
                    onLoginSuccess(sessionCommand, _user, apiResult);
                }
            },
                          (WebContextException error) => {
                OnError(new ApiException(1, "Could not login.", error));
            });
        }
Example #2
0
 public static void Login(string username, string password,
                          OnLoginSuccessAction onLoginSuccess, OnLoginFailedAction onLoginFailed)
 {
     Login(null, username, password, onLoginSuccess, onLoginFailed);
 }