Storing currently logged in user / session parameters

2 posts, 0 answers
  1. Filip
    Filip avatar
    35 posts
    Member since:
    Jul 2013

    Posted 19 Jul 2013 Link to this post

    Hello,
    I am quite new at all this. I'm trying to keep track of currently logged in user throughout the session. I cannot use Everlive services, and my users is read from database. I also have some more session parameters, which I dont know how to store. I am actually storing userdata(username and password) in a kendo.observable object, but the problem is that my dataSource object is probably initialized before userdata is set:

    i have something like this: 
    on login:

    usersModel.currentUser.set('username', username);
    usersModel.currentUser.set('password', password);

    after login this data from this data source is retrieved. 
    var eventsDataSource = new kendo.data.DataSource({
                schema: {
                    model: eventModel
                },
                transport: {
                    read: {
                      url: WCF + "/GetOrganizerEventsJSON",
                      data: { strUser: usersModel.currentUser.username, strPasswort: usersModel.currentUser.password },
                      contentType: "application/json; charset=utf-8",
                      dataType: "jsonp",
                      crossDomain: true
                    }
                }
            });
            return {
                events: eventsDataSource
            };

    Problem is that username and password are "" (empty strings) in the request. I also tried with defining data as a function, but no success, still empty strings.
    data: { strUser: usersModel.getCurrentUser().username, strPasswort: usersModel.getCurrentUser().password }
  2. Filip
    Filip avatar
    35 posts
    Member since:
    Jul 2013

    Posted 19 Jul 2013 Link to this post

    I managed to find a solution by defining whole data as a function.

    transport: {
                    read: {
                      url: WCF + "/GetOrganizerEventsJSON",
                      data: function() {return usersModel.currentUserFnc();},
                      contentType: "application/json; charset=utf-8",
                      dataType: "jsonp",
                      crossDomain: true
                    }
                },

    function currentUserFnc() {
           return {strUser: currentUser.username, strPasswort: currentUser.password};
    }

    Still, if there is some better way to manage "session" data, I'd be grateful for a hint. 

    Thanks!

Back to Top