How to verify user login using fnServerData?

How to verify user login using fnServerData?

leonardolimaleonardolima Posts: 5Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
Hi,

I'm trying to build the following logic:
1) Override the fnServerData function
2) On the fnServerData function I will have another function that will verify if user has the session expired, if yes show a login form.
3) After the user be re-logged I need re-apply the user request, for exemple, my user clicked on page number 5, so I need get this request and save and after login I need re-apply.

My problem now is how to save this state? To reload the data I know that I need use fnDraw(), but always when I call fnDraw the pagination get lost, anyone can help me ?

Best Regards,
Leonardo Lima

Replies

  • allanallan Posts: 65,442Questions: 1Answers: 10,870 Site admin
    Daft question perhaps, but how can they click on page 5 without being logged in? Or do you show just the first page without log-in and require a log-in for other features?

    I think you probably want to use the bStateSave option and DataTables will do the state saving for you.

    Allan
  • leonardolimaleonardolima Posts: 5Questions: 0Answers: 0
    Sorry,

    This scenario happens when the user login and leave the system idle. The DataTable is already rendered, so I'm using server side processing, so the user can click on the pagination number, and DataTable will trigger a new ajax request OK?

    So I'm thinking something like this

    [code]
    oSettings.jqXHR = $.ajax( {
    "url": sSource,
    "data": aoData,
    "success": function (json) {
    if(!json.NotAuthorized){
    $(oSettings.oInstance).trigger('xhr', oSettings);
    fnCallback( json );
    }else{
    //show a ajax login form
    //after user logged again
    //repeat the post with the same value (in this case the action of user click on pagination number)
    }
    }
    });
    [/code]

    The ajax login form is done, I just can't figure out how repost the action from user...

    Thanks again
This discussion has been closed.