我一直在嘗試開發適用於應用程序的基於適配器的身份驗證,我不確定挑戰處理程序爲什麼不會在此觸發。挑戰不處理與基於適配器的身份驗證的挑戰
客戶端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開發者控制檯返回請求超時。在Android設備上執行應用程序時,Logcat會顯示狀態代碼201.我只能假定對象是使用從字段收集的信息成功創建的,但是,處理程序根本不提交憑證。
任何類型的建議將不勝感激。如果我的帖子看起來很愚蠢,我會提前道歉,因爲我對MobileFirst和Web技術一般都不太熟悉。
狀態碼爲201表示。實體格式由Content-Type標題字段中給出的媒體類型指定。另一方面,原始服務器必須在返回201狀態碼之前創建資源。 201狀態碼指示請求已成功,因此已創建資源(例如新頁面)。 –
所以請分享您的適配器代碼。或流動適當的文檔https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/all-tutorials/ –
謝謝您的回覆哈桑。我在以下鏈接中添加了適配器的js和xml文件的代碼:https://jsfiddle.net/srvc0pk7/ – Willarch