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

Using logged in user to filter

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

    Using logged in user to filter

    Hi guys!

    I Used to have a UX with controls for username and password and in the server side event like in a mobile security situation I would put the following code :

    Code:
    function onLogin as v (e as p)
    
    dim session.UserFirstName as c = ""
    dim session.UserLastName as c = ""
    dim session.UserUserName as c = ""
    
    if e.loginSucceeded = .T. then 
    	dim cn as sql::Connection
    	dim args as sql::Arguments
    	dim SQL as c
    	
    '	SQL = "SELECT userid,  Firstname, Lastname FROM websecurityusers WHERE UserName = :UserName"
    	args.set("UserName",e.username)
    '	if cn.open("::name::ConnectionToExpenseRequests") 
    	'	if cn.Execute(SQL,args)
    		'	if cn.ResultSet.nextRow() ' a record was found
    			'	session.UserFirstName = cn.ResultSet.data("Firstname")
    				'session.UserLastName = cn.ResultSet.data("Lastname")
    				session.UserUserName = e.username
    		'	end if 
    		'end if 
    		'cn.close()
    	end if 
    	if session.UserLastName <> ""
    		e.userNameFriendly = alltrim(session.UserFirstname)+" "+session.UserLastname 
    	end if 
    
    	
    
    end function
    Ive started a new project and I created a login component for the web security system a la : https://puu.sh/wdcze.png

    So It logs in fine. but I don't know where to put the code to set the logged in user to a session variable. I tried adding it to the on Login page in the UX inserted into the redirected page. But it stays blank.
    The HTML page cant have server side events, and the login builder doesn't have anywhere to set server side events.


    So my question. When using a Login Builder. How do you set the current logged in user to a session variable?

    #2
    Re: Using logged in user to filter

    So... you don't want to... or can't... use the UX Integrated Login process?

    If not... in your Redirect page - login" UX, in the Server-side onDialogInitialize event, you can use the Context.Security.CurrentUser property to get the current logged in user.

    Comment


      #3
      Re: Using logged in user to filter

      Hey man thanks for the reply. Not sure what you mean by UX integrated login process. Ill try the CurrentUser thing this morning and report back.

      Comment


        #4
        Re: Using logged in user to filter

        C Result = A5ws_GetCurrentUser() in onDialogInitialize.
        This worked ! Thanks for pointing me in the right direction.

        Comment


          #5
          Re: Using logged in user to filter

          You should be using Context.Security.CurrentUser instead. The Context Object is the current methodology.

          Comment


            #6
            Re: Using logged in user to filter

            Side note: avoid using "DIM" with the "session" pointer variable. Just write:

            session.somevar = "Your string value" ' Make sure you only use a string/character value here!!!

            Older versions of Alpha did not handle "DIM session.somevar" the way we expected.
            https://www.alphasoftware.com/docume...0Variables.xml

            Comment


              #7
              Re: Using logged in user to filter

              Hi David,

              Where is the Context.Security.CurrentUser to be found and is there a video or documentation on this?
              John

              Currently Using Alpha ver 12.4.4.4. Build: 4346; Addins: 4889 against MySql databases

              Church Job Finder
              A Church of England Enabling Recruitment Partner "Right People, Right Place, Right Time"

              Comment


                #8
                Re: Using logged in user to filter

                Originally posted by doula View Post
                Hi David,

                Where is the Context.Security.CurrentUser to be found and is there a video or documentation on this?
                http://downloads.alphasoftware.com/a....html#Security
                Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                Comment


                  #9
                  Re: Using logged in user to filter

                  Thanks for info Stephen.

                  This is helpful to an extent, but I'm still confused as to how the Context.Security.CurrentUser is used in the code posted by John. (Original question).

                  Please would you mind showing how it is done.
                  Regards
                  Keith Hubert
                  Alpha Guild Member
                  London.
                  KHDB Management Systems
                  Skype = keith.hubert


                  For your day-to-day Needs, you Need an Alpha Database!

                  Comment


                    #10
                    Re: Using logged in user to filter

                    Keith, my reply was to the previous user asking about documentation for the context.security method.

                    John's original post is setting session variables based on a SQL query. I don't do things this way, I use a login processing page to set any session variables I'm going to need.
                    But, wherever you used xbasic security functions such as A5ws_GetCurrentUser() has been superseded by the context security methods as David pointed out.

                    So, for example in server-side xbasic, you could simply do something like:
                    e.control.Result = "Current Logged-In User = " + Context.Security.CurrentUser

                    or
                    dim UserName as c = e.DataSubmitted.User
                    e.control.Result = UserName + " Belongs To Role: " + Context.Security.GetUserRoles(UserName)
                    Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                    Comment


                      #11
                      Re: Using logged in user to filter

                      Does the term superseded mean that getcurrentuser() will eventually be phased out? If so I got a lot of work to do as nearly ALL of my components use this in one way or another. Am I ok to leave them or should I begin making changes now?
                      NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                      Comment


                        #12
                        Re: Using logged in user to filter

                        Not superseded. E.g. A5WS_GetCurrentUser() calls into Context.Security.CurrentUser... so they both end up at the same spot... so no worries. Selwyn is using the A5WS functions in his latest samples... and what's good enough...

                        I'll tend to use the Context stuff because it's in my head now.

                        Comment


                          #13
                          Re: Using logged in user to filter

                          That word superseded is not mine ... it is quoted directly from Alphas' context security object documentation.

                          "This object supersedes other ways to access web application server context"

                          Given that, I still use A5WS methods, but I have also started using the context security methods. I will eventually replace the older methods, I just have other priorities at the moment.
                          Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                          Comment

                          Working...
                          X