Authentication 成功执行isCustomResponse()后未调用handleChallenge() 我正在使用IBM MaBiLa1平台基础应用程序7开发一个应用程序,使用AngularJS和ION。对于身份验证,我使用基于适配器的身份验证

Authentication 成功执行isCustomResponse()后未调用handleChallenge() 我正在使用IBM MaBiLa1平台基础应用程序7开发一个应用程序,使用AngularJS和ION。对于身份验证,我使用基于适配器的身份验证,authentication,ibm-mobilefirst,Authentication,Ibm Mobilefirst,我只有一个域来保护应用程序和所有过程。我已经定义了一个登录控制器和一个处理身份验证相关活动的LoginCallangeHandler服务: 我是基于以下几点: 当我登录应用程序时,通过以下步骤验证工作正常 步骤1: 调用ch.submitAdapterAuthentication(选项,ch.submitLoginCallback) 第二步: 成功调用适配器后,将调用以下命令 ch.submitLoginCallback = function(response) { co

我只有一个域来保护应用程序和所有过程。我已经定义了一个登录控制器和一个处理身份验证相关活动的LoginCallangeHandler服务:

我是基于以下几点:

当我登录应用程序时,通过以下步骤验证工作正常

步骤1:
调用
ch.submitAdapterAuthentication(选项,ch.submitLoginCallback)

第二步:
成功调用适配器后,将调用以下命令

ch.submitLoginCallback = function(response) {
            console.log("submitLoginCallback.response ",response);
            var isLoginFormResponse = ch.isCustomResponse(response);
            console.log("submitLoginCallback.isLoginFormResponse ",isLoginFormResponse);
            if (isLoginFormResponse){
                console.log("submitLoginCallback.calling  ");
                ch.handleChallenge(response);
            } 
        };
第三步:
调用ch.isCustomResponse=function(response)
,返回true或false

ch.isCustomResponse = function(response){
            console.log("isCustomResponse.responseJSON ",response);
            //alert("response")
            if (!response || !response.responseJSON || response.responseText === null) {
                return false;

            }

            console.log("isCustomResponse.response.responseJSON ",response.responseJSON);
            console.log(typeof(response.responseJSON.authRequired) !== 'undefined');
            if (typeof(response.responseJSON.authRequired) !== 'undefined'){
                //ch.handleChallenge(response);
                return true;
            } else {
                return false;
            }
        };
步骤4:
调用
ch.handleChallenge=function(response)
,我们将在其中处理usr身份验证的成功或失败

问题是,当身份验证失败或服务器会话注销或服务器会话超时时,在服务器适配器端调用AuthRequired方法,该方法
returnsauthRequired=true

function onAuthRequired(headers, errorMessage){
    return {
        authRequired: true,
        errorMessage: errorMessage
    };
}
在客户端,调用了
ch.isCustomResponse=function(response)
,但之后不调用
ch.handleChallenge=function(response)
。执行在
ch.isCustomResponse
函数处终止,并且不会自动调用
ch.handleChallenge
。如果我像这样手动呼叫

if (typeof(response.responseJSON.authRequired) !== 'undefined'){
                //ch.handleChallenge(response);
                return true;
            } else {
                return false;
            }
登录时,将执行两次
ch.handleChallenge()


谁能告诉我怎么解决这个问题吗?当身份验证失败或服务器会话注销或服务器会话超时时,如何在
ch.isCustomResponse()
返回
authRequired=true
false
时自动调用
ch.handleChallenge()

首先,您需要在登录页面(用户提供凭证并按Login)上显示该用户,或者如果您是通过代码登录的,则需要调用此命令

ch.submitdapterauthentication(选项,ch.submitLoginCallback)


身份验证失败或服务器会话注销或服务器会话超时时

首先,您需要在登录页面(用户提供凭证并按Login)上显示该用户,或者如果您是通过代码登录的,则需要调用此命令

ch.submitdapterauthentication(选项,ch.submitLoginCallback)


谢谢,目前我也在做同样的事情,但我的问题是在成功执行适配器后,会自动调用ch.isCustomResponse(),响应为{authRequired:true,errorMessage:null},但不会自动调用ch.handleChallenge()函数。如果在这种情况下,我从ch.isCustomResponse()手动调用ch.handleChallenge()函数,那么在执行ch.submitAdapterAuthentication(选项,ch.submitLoginCallback)时,ch.handleChallenge()函数被调用了两次。请给出解决此问题的建议和建议。每当isCustomResponse返回YES值时,Worklight必须调用handleChallenge方法。从isCustomResponse中尝试重新运行“YES”。我没有可用的代码。谢谢,目前我也在这样做,但我的问题是,在成功执行适配器后,会自动调用ch.isCustomResponse(),并响应{authRequired:true,errorMessage:null},但不会自动调用ch.handleChallenge()函数。如果在这种情况下,我从ch.isCustomResponse()手动调用ch.handleChallenge()函数,那么在执行ch.submitAdapterAuthentication(选项,ch.submitLoginCallback)时,ch.handleChallenge()函数被调用了两次。请给出解决此问题的建议和建议。每当isCustomResponse返回YES值时,Worklight必须调用handleChallenge方法。从isCustomResponse中尝试重新运行“YES”。我没有工作代码。