3

我有一个网站——使用Visualize.js——有一个简单的登录/注销功能。每次登录时,我都会调用该authenicateUser()函数并注销destroySession()。当我尝试登录然后注销然后再次登录时,当我尝试呈现我现有的报告时,我得到这个抛出的错误:

HTTP Status 401 - Full authentication is required to access this resource

功能authenicateUser()destroySession()如下图所示:

function authenticateUser () {
    var myConfig = {
        auth : {
            name     : "superuser",
            password : "superuser"
        }
    };
    visualize.config( myConfig );
}

function destroySession() {
    visualize( function ( v ) {
        // Logout form JRS and finish the session.
        v.logout().done( function () {
        } );
    } )
}

我想指出,当我第一次登录我的帐户时,不会抛出此错误并完美呈现报告。

为什么注销后重新登录后会出现这种情况?

4

2 回答 2

5

这似乎对我有用。所以我首先调用了 Visualize.config( config ) 以便我可以存储常用配置,以便在可视化调用之间共享它们,然后调用 login 方法以便我可以使用提供的身份验证对象执行身份验证。我的参考:http: //community.jaspersoft.com/wiki/visualizejs-api-notes-and-samples-v56

        visualize.config( config );
        visualize( function ( v ) {
            v.login( config );
        } );

这个解决方案虽然不在他们的文档中,但我把它们一块一块地放在最后解决了这个问题。

于 2015-06-02T16:07:20.703 回答
1

文档包含了这个问题的解决方案,尽管它不是很明确。请参阅文档链接中的示例代码和示例链接

visualize.config({
  auth: {
      name: "superuser",
      password: "superuser"
  }
});

在“可视化”调用之间共享通用配置

Just a note: Actually when you login you need to logout at some appropriate event. This depends on your application requirement e.g. if you are embedding reports within an existing web application, it seems more appropriate to link it existing application login/lougut

于 2015-07-08T20:31:16.723 回答