jasper-reportsvisualize

Visualize.js authentication error after second login


I have a website—utilizing Visualize.js—that has a simple login/logout feature. Everytime I login I call the authenicateUser() function and logout destroySession(). When I try login and then logout and then login again, when I try to render my existing reports I get this thrown error:

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

The functions authenicateUser() and destroySession() are shown below:

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 my account this error is not thrown and renders the reports perfectly.

Why is this happening after logout and then login again?


Solution

  • This seemed to have worked for me. So I called visualize.config( config ) first so that I can store common configuration, to share them between visualize calls and then called the login method so that I can perform authentification with provided auth object. My reference: 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 solve the problem.