﻿function CheckUser() {
    var login = GetElementById('LoginInput');
    var password = GetElementById('PasswordInput');
    if ((login && password) && login.value != "" && password.value != "") {
        PublicSite.WebServices.ValidateUsersWebService.set_defaultSucceededCallback(ValidateUserSucceededCallback);
        PublicSite.WebServices.ValidateUsersWebService.set_defaultFailedCallback(ValidateUserFailedCallback);
        PublicSite.WebServices.ValidateUsersWebService.ValidateUser(login.value, password.value);
    }
}

// This is the callback function that processes the Web Service return value.
function ValidateUserSucceededCallback(result, userContext, methodName) {
    // если пользователь успешно прошёл валидацию
    if (result == "valid") {
        window.location.href = '/Client/AccountSummary.aspx';
    }
    else {
        var password = GetElementById('PasswordInput');
        password.value = "";
        
        var errorMessage = GetElementById('LoginErrorText');
        errorMessage.innerHTML = result;
    }
}

// This is the callback function that processes the Web Service return value.
function ValidateUserFailedCallback(error, userContext, methodName) {
}