我正在使用javascript代码登录,想知道如何使用window.df.apis库来检查用户会话是否仍然存在。
    window.df.apis.user.login({body: body}, function (response) {
        window.authorizations.add("X-DreamFactory-Session-Token", new ApiKeyAuthorization("X-Dreamfactory-Session-Token", response.session_id, 'header'));
        jQuery.mobile.changePage("#index");
    }, function(response){
        $("#login-status").html(window.app.getErrorString(response));
    });谢谢
发布于 2015-01-13 04:27:14
从提供的example jQuery ToDo app (此代码片段来自app.js):
function checkSession() {
$("#loading").show();
// check for existing session, relevant when code is hosted on the dsp
window.df.apis.user.getSession({"body":{}}, function (response) {
    $("#loading").hide();
    // existing session found, assign session token
    // to be used for the session duration
    var session = new ApiKeyAuthorization("X-Dreamfactory-Session-Token",
        response.session_id, 'header');
    window.authorizations.add("X-DreamFactory-Session-Token", session);
    runApp();
}, function (response) {
    $("#loading").hide();
    // no valid session, try to log in
    doLogInDialog();
});
}https://stackoverflow.com/questions/27888088
复制相似问题