Visualize.js authentication error after second login

I have a Visualize.js website that has a simple login / logout functionality. Every time I login, I call the function authenicateUser()

and log out destroySession()

. When I try to log in and then log out and then log back in, when I try to display my existing reports, I get this abandoned error:

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

      

The following are the functions authenicateUser()

and 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 () {
        } );
    } )
}

      

I would like to point out that when I first login to my account, this error is not thrown and displays the reports fine.

Why does this happen after logging out and then logging back in?

+3


source to share


2 answers


It seemed to work for me. So I first called visualize.config (config) so that I can store the shared config, share it between rendering calls and then call the login method so that I can authenticate with the auth object provided. My link: http://community.jaspersoft.com/wiki/visualizejs-api-notes-and-samples-v56

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

      



This solution was not in their documentation though, but I put them piece by piece to finally fix the problem.

+4


source


The documentation contains a solution to this problem, although it is not very explicit. See sample code and sample link from documentation link

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

      



Share shared configuration between render calls

Just a side note: In fact, when you log in, you need to log out of some suitable event. It depends on your application, for example. if you are embedding reports in an existing web app, it seems more appropriate to link it to an existing login / lougut app

+1


source







All Articles