Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Jun 2012
    Location
    Berlin
    Posts
    4

    Question User Authentication - Login

    Hello Lightstreamer community,

    i am trying to realize a user authentication with a simple login form.
    on click to submit button i call the createEngine function in whose event i set the username and password to the connection object.

    Code:
    engine.connection.setUserName(document.getElementById("user").value);
    engine.connection.setPassword(document.getElementById("password").value);
    these two information become sent to the notifyuser function of the metadataadapter, where i check if the login is correct.
    if not i throw AccessException.
    here comes the first problem: the user should now try to log in again, but when he types in a new user / pass and clickes again on submit, there comes an Exception 'ER createEngine() has already been called createEngine '. I tried to avoid it by calling
    Code:
    engineRef.changeStatus("DISCONNECTED");
    but engineRef is null at this point of time.

    second problem is that when i check up the login and it is correct, how can i redirect to the next page?

    Thanks mluecke

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hello There,

    first of all, I suggest you to use the new Lightstreamer JavaScript client version 6 instead of using version 5. The new client heavily simplifies the engine and connection handling so that it is much easier to code with it.
    Version 6 is currently in beta version but the final release will be deployed in a matter of days.

    NOTE: all of the below comments only apply to the old client version (html client 5)


    when he types in a new user / pass and clickes again on submit, there comes an Exception 'ER createEngine() has already been called createEngine '.
    If in the code that is called upon submission there is a createEngine call then the message is correct: you should call it only once.

    but engineRef is null at this point of time.
    during the onEngineReady execution you should save the engineRef pointer somewhere (e.g.: a global variable) so that you can access it later again. In this case do not forget to implement the onEngineLost event to delete the saved reference.

    when i check up the login and it is correct, how can i redirect to the next page?
    This heavily depend on your interaction design.
    Note that if you redirect the user to a different html page you would lose the connection (i.e. you would need to authenticate again).
    Check the client guide for an overview of website-integration possibilities: http://www.lightstreamer.com/distros...ient%20Dev.pdf

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 10:42 PM.