Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Logged in as

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Logged in as

    Trying to display a message that shows which account is being used to log into my app. I wrote an xbasic function as follows:

    function getlogin as c (e as p)

    dim session.UserID as c
    dim user as c

    session.UserID = a5ws_getcurrentuser()
    user = "var ele = {dialog.object}.getPointer('logged_in_as'); ele.innerHTML = '"+js_escape(session.UserID)+"';"
    getlogin = user
    end function

    Inside a UX component, I created a label with the variable name "logged_in_as", and have a client-side event for "onInitializeComplete that fires an ajaxcallback:

    {dialog.object}.ajaxCallback('','','getlogin','','',{deviceOfflineFunction: function() { }});

    What I have noticed is that this seems to work ok for testing in a web browser. I say ok because sometimes the username value does not appear and I have to refresh the browser for it to appear. But what I also notice is that when I create a phonegap build, I can't get the username to appear at all. Wondering if there is a better place to trigger this xbasic function. Perhaps as a server side event instead of client side? Any thoughts would be appreciated.

    Thanks.

    #2
    Re: Logged in as

    I wouldn't use session vars in a mobile app.

    Are you logged in when onInitializeComplete fires? Certainly not the first time. I wouldn't use that event... but it's unclear, overall, what you're trying to do.

    If you're logging in and just want the username then use the server-side onLogin event and send back your javascript in e.javascript.

    Comment


      #3
      Re: Logged in as

      I did not mention that I am doing persistent login as well. So with that said, can I use server-side onLogin?

      I have a login UX using persistent login. That takes you to an embedded UX where my main application lives. It is within that main application that I want the "logged in as" message to appear. I would think that I am logged in when oninitializecomplete fires, because this is in my application UX, but I could be wrong.

      Comment


        #4
        Re: Logged in as

        Been reading up on state variables. Thanks for the suggestion.

        I've got this in 'onDialogInitiatlize'

        e._state.user = a5ws_getcurrentuser()


        Now I basically want a control like a label or textbox to display that current user. I am struggling with the client side syntax. Been looking through the forums and online, but can't seem to formulate that final syntax.

        Maybe client-side 'onRenderComplete' would be the place for my javascript? But what exactly would the syntax be?

        Basically need to take this state variable propertly and put it in a variable I created called "logged_in_as".

        Thanks.

        Comment


          #5
          Re: Logged in as

          Ok... I think you've been wrapping yourself around the axle through a couple of posts. The persistent login is an important piece of information. Here is just one way to organize stuff... there are so many ways to work with this process.

          Using Alpha's Persistent Login example UX, have a look at the XBasic function xbLogin.

          Instead of sending back javascript statements, let's call a javascript function instead. The sample UX was already setting up token in a state var... so let's do the same for the guid and userName Anything the xbLogin return was doing... we'll do in our function named completePersistLogin().

          So, the end of xbLogin looks like this...
          Code:
          jsOut = "completePersistLogin();"
          xbLogin = jsOut
          e._state.token = token
          e._state.userName = userName
          e._state.guid = e.tmpl.guid
          And completePersistLogin() looks like this...
          Code:
          function completePersistLogin(){
          
          	var guid = {dialog.object}.stateInfo['guid'];
          	var userName = {dialog.object}.stateInfo['userName'];
          	var token = {dialog.object}.stateInfo['token'];
          	
          	{dialog.object}.panelSetActive('PANEL_APPLICATION');
          	localStorage.setItem(guid,token);
          	localStorage.setItem('userName',userName);
          	
          	//embedded child UX
          	var cObj = {dialog.Object}.getChildObject('UX_PERSISTENTLOGIN_EMBEDDED');
          	var cEle = cObj.getPointer('logged_in_as');
          	cEle.innerHTML = userName;	
          	
          	var ele = {dialog.object}.getPointer('LOGIN_ERRORS');
          	ele.innerHTML = '';
          
          }
          This function...

          Sets the Active Panel to the application
          Gets all our state vars
          Sets up the localStorage items we need
          Reaches into the Embedded Child UX and sets 'logged_in_as'

          In the parent UX onRenderComplete we only have add one new line for userName... in the same are where the state var 'token' is being set...
          Code:
          {dialog.object}.stateInfo['userName'] = userName;
          In the Embedded Child UX, onRenderComplete...
          Code:
          var pObj = {dialog.Object}.getParentObject();
          if(pObj){
          	var userName = pObj.stateInfo['userName'];
          	var ele = {dialog.Object}.getPointer('logged_in_as');
          	ele.innerHTML = userName;
          }
          Here... we reach into the Parent UX... and get our state var for userName.

          Here are the 2 UX Components I am working with...
          UX_Persist_Login.zip

          Comment


            #6
            Re: Logged in as

            Thanks so much for laying this out. One question though, I did take your 2 UX components and load them into my server. When I try to login with these example components, I get the following error message:

            error_message.JPG

            Comment


              #7
              Re: Logged in as

              No errors here. cObj is set up in the Javascript function completePersistLogin() which is called from xbLogin if a login is ok. cObj is a pointer to the embedded UX... which should be available by the time a login happens. Is security for the parent and child UX set to always allowed?

              Comment


                #8
                Re: Logged in as

                There was a UX not set to always allowed. I changed that and it started working. Thought I was doing good, but now I am getting two different error messages. One says the error message about the pointer, then there is a message that says invalid or unexpected token. I even deleted the UX components you gave me, cleared publishing history, brought them back in again, made sure everything was set to always allowed, republished the UX components with security tables. Still acting up. Got me stumped as to why it is not working. Will keep messing with it.

                Comment


                  #9
                  Re: Logged in as

                  Getting weird results. It started working again in my browser, but then after I did a refresh, I started getting the errors again. All without me making any changes.

                  Comment


                    #10
                    Re: Logged in as

                    for an outsider looking in {
                    why an outsider:
                    i don't have version 12,
                    i don't have a clue what is persistent login ux
                    but: curiosity, i always have }
                    you have this login business in few threads and still struggling.

                    so here is my take on this.
                    persistent login usually means that the login information is stored in the browser / device local storage and the ux in question when opened queries that info and if correct then proceeds with the program. this is the logic as far as i am concerned.
                    so you have two options
                    if you have no desire for off line capability then don't worry about local storage just query the a5ws_getCurrentUser() and fill in the value or if you want to have off line capability then query the local storage and get the value and populate the user name. in either case onDialogInitialize is not going to be better but onDialogExecute will be better since it will fire all the time. in either case don't worry about session storage either. the real way to do is to query the user name for mission critical actions every time. in sessions people may walk away and the session will be alive.
                    if you run your dialog / ux in web browser and open up the developer tools then you will see the local storage items and you can call them and set the value.

                    here is a screencast to show you how local storage works. and i am sure you can examine your ux and find the stored names and query them easily.
                    https://www.screencast.com/t/b8hQ8AaXloU7

                    edit: in my example i set the local storage, in yours the persistent login ux, i think is setting it. so you need to concentrate get local storage action only.

                    to prove this point i have made another screencast and populated the user name via afterrendercomplete javascript action.
                    and you can see even closing and opening the dialog has no effect on the logged in user, it is preserved. persistent right!

                    https://www.screencast.com/t/hVyZK33QES
                    Last edited by GGandhi; 09-27-2017, 09:11 PM.
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


                      #11
                      Re: Logged in as

                      Davidk, here is a video of me trying to run the UX you sent me:

                      https://youtu.be/QHjNd7yJ4aA

                      Not sure why it is throwing the various errors at me.

                      Govindan, thanks for the suggestions. I did watch your videos, and that was helpful. I tried to implement what you suggested, and the issue I have is that it doesn't always populate the name, and I have to hit refresh to get the field to populate. I can see in the dev console where it is storing the name in localstorage. But for some reason the onrendercomplete javascript doesn't seem to work the first time, and I have to hit refresh.

                      Comment


                        #12
                        Re: Logged in as

                        I have a login UX using persistent login. That takes you to an embedded UX where my main application lives.
                        i see that you have the application in an ux/dialog that is embedded into the login ux, that may be it, preventing from loading onRnderComplete event. i will test again later on to see if anything like that will interfere.
                        thanks for reading

                        gandhi

                        version 11 3381 - 4096
                        mysql backend
                        http://www.alphawebprogramming.blogspot.com
                        [email protected]
                        Skype:[email protected]
                        1 914 924 5171

                        Comment


                          #13
                          Re: Logged in as

                          Did you change the name of the embedded UX? Did you change the Component alias property value? Did you change any of the properties of the Embedded Object?

                          I know Gandhi is using a version of Alpha that is a different product release and over 4 years old to help solve a problem in a current version... but... what Version build are you using?

                          Comment


                            #14
                            Re: Logged in as

                            I am on version 12.4.4.5, build 4491.

                            When I brought in your 2 UX components, I left the embedded UX name alone, since it was pointing correctly to your secondary UX. When I tried inputting the code into my UX, I did change the embedded UX to point correctly to my main application.

                            As far as changing the component alias property value or the properties of the embedded object, I did not change anything there. Should I have?

                            Comment


                              #15
                              Re: Logged in as

                              for the embedded object, if you are asking if I added the code for client side render complete that you included, I did do that.

                              Comment

                              Working...
                              X