挑战不处理基于适配器的身份验证的挑战
Challenge does not handle challenge with adapter based authentication
我一直在尝试为应用程序开发基于适配器的身份验证,但我不太清楚为什么这里没有触发质询处理程序。
客户端main.js:
var AuthenticationHandler = WL.Client.createChallengeHandler("EventAuthRealm");
AuthenticationHandler.isCustomResponse = function(response) {
if (!response || !response.responseJSON || response.responseText === null) {
return false;
}
if (typeof(response.responseJSON.authStatus) !== 'undefined') {
return true;
} else {
return false;
}
};
AuthenticationHandler.handleChallenge = function(response) {
var authRequired = response.responseJSON.authRequired;
if (authRequired == false) {
WL.logger.debug("done");
busyIndicator.hide();
AuthenticationHandler.submitSuccess();
toEventList(); //function to navigate to next page
} else if (authRequired == true) {
WL.logger.debug("false");
busyIndicator.hide();
AuthenticationHandler.submitFailure();
WL.Logger.debug(response.responseJSON.errorMessage);
}
};
登录函数:
function login() {
var reg = $("#attendeeId").val();
var userpw = $("#attendeePw").val();
busyIndicator.show();
var invocationData = {
adapter: "eventdbAdapter",
procedure: "submitAuthentication",
parameters: [reg, userpw]
};
AuthenticationHandler.submitAdapterAuthentication(invocationData, {});
};
HTML登录页面代码:
<div data-role="page" id="eventloginpage">
<div data-role="header" align="center" data-theme="b">Event app</div>
<div data-role="content" style="padding: 15px" id="wat">
<input type="text" name="attId" id="attendeeId" placeholder="Attendee ID">
<input type="password" name="password" id="attendeePw" placeholder="Attendee Password">
<!-- Buttons here -->
<a href="#" data-role="button" id="loginButton" data-theme="b" onclick="login();">Login</a>
<a href="#" data-role="button" id="button" onclick="logout();">Logout for now</a>
</div>
<div data-role="footer" align="center">Text</div>
</div>
如果这可能相关,我按照使用 pagecontainer 更改的教程构建了应用程序的多页组件。
示例:
function toEventList() {
$(':mobile-pagecontainer').pagecontainer('change', 'eventpage.html');
}
每当我执行登录功能时,一切都按预期工作,直到调用 submitAdapterAuthentication。
Google 开发控制台 returns 请求超时。在 Android 设备上执行应用程序时,Logcat 显示状态代码 201。我只能假设使用从字段收集的信息成功创建了对象,但是,处理程序没有提交凭据。
如有任何建议,我们将不胜感激。如果我的 post 看起来很愚蠢,我提前道歉,因为我对 MobileFirst 和一般的 Web 技术不太熟悉。
了解您使用的 MFP 版本会很有帮助,这样您就可以查看相应的文档。
请确保以下内容已在 wlCommonInit() 中实现。从此处的文档可以看出,Documentation,需要联系工作灯服务器
WL.Client.connect(
{
onSuccess: onConnect成功,
onFailure: 连接失败
});
我想通了为什么之前不能正常工作。在适配器方面,我没有像示例中所示那样对 submitAuthentication() 中的测试登录值使用严格的相等运算符。我假设其他类型的相等运算符会起作用,但是,情况似乎并非如此。据我所知,这没有写在任何文档中。
我之前提到的 401 错误似乎是 MobileFirst 服务器根据文档对其中一个内置组件执行的检查。
我还确保清理服务器并在其上重新部署应用程序。
我一直在尝试为应用程序开发基于适配器的身份验证,但我不太清楚为什么这里没有触发质询处理程序。
客户端main.js:
var AuthenticationHandler = WL.Client.createChallengeHandler("EventAuthRealm");
AuthenticationHandler.isCustomResponse = function(response) {
if (!response || !response.responseJSON || response.responseText === null) {
return false;
}
if (typeof(response.responseJSON.authStatus) !== 'undefined') {
return true;
} else {
return false;
}
};
AuthenticationHandler.handleChallenge = function(response) {
var authRequired = response.responseJSON.authRequired;
if (authRequired == false) {
WL.logger.debug("done");
busyIndicator.hide();
AuthenticationHandler.submitSuccess();
toEventList(); //function to navigate to next page
} else if (authRequired == true) {
WL.logger.debug("false");
busyIndicator.hide();
AuthenticationHandler.submitFailure();
WL.Logger.debug(response.responseJSON.errorMessage);
}
};
登录函数:
function login() {
var reg = $("#attendeeId").val();
var userpw = $("#attendeePw").val();
busyIndicator.show();
var invocationData = {
adapter: "eventdbAdapter",
procedure: "submitAuthentication",
parameters: [reg, userpw]
};
AuthenticationHandler.submitAdapterAuthentication(invocationData, {});
};
HTML登录页面代码:
<div data-role="page" id="eventloginpage">
<div data-role="header" align="center" data-theme="b">Event app</div>
<div data-role="content" style="padding: 15px" id="wat">
<input type="text" name="attId" id="attendeeId" placeholder="Attendee ID">
<input type="password" name="password" id="attendeePw" placeholder="Attendee Password">
<!-- Buttons here -->
<a href="#" data-role="button" id="loginButton" data-theme="b" onclick="login();">Login</a>
<a href="#" data-role="button" id="button" onclick="logout();">Logout for now</a>
</div>
<div data-role="footer" align="center">Text</div>
</div>
如果这可能相关,我按照使用 pagecontainer 更改的教程构建了应用程序的多页组件。
示例:
function toEventList() {
$(':mobile-pagecontainer').pagecontainer('change', 'eventpage.html');
}
每当我执行登录功能时,一切都按预期工作,直到调用 submitAdapterAuthentication。
Google 开发控制台 returns 请求超时。在 Android 设备上执行应用程序时,Logcat 显示状态代码 201。我只能假设使用从字段收集的信息成功创建了对象,但是,处理程序没有提交凭据。
如有任何建议,我们将不胜感激。如果我的 post 看起来很愚蠢,我提前道歉,因为我对 MobileFirst 和一般的 Web 技术不太熟悉。
了解您使用的 MFP 版本会很有帮助,这样您就可以查看相应的文档。
请确保以下内容已在 wlCommonInit() 中实现。从此处的文档可以看出,Documentation,需要联系工作灯服务器
WL.Client.connect( { onSuccess: onConnect成功, onFailure: 连接失败 });
我想通了为什么之前不能正常工作。在适配器方面,我没有像示例中所示那样对 submitAuthentication() 中的测试登录值使用严格的相等运算符。我假设其他类型的相等运算符会起作用,但是,情况似乎并非如此。据我所知,这没有写在任何文档中。
我之前提到的 401 错误似乎是 MobileFirst 服务器根据文档对其中一个内置组件执行的检查。
我还确保清理服务器并在其上重新部署应用程序。