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

Who is logged in?

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

    #16
    Re: Who is logged in?

    Steve,

    many thanks for the last suggestion. I moved the code up and it works as expected.

    Andy Sigrist

    Comment


      #17
      Re: Who is logged in?

      During testig of the new function I noted that a record is being created in Web_Log.Dbf regardless of whether the user entered a valid Username / Password or not.

      If a user enters a wrong Username or Password, the system does not log the user in, but a record is still added in Web_Log.Dbf. I tried to write Xbasic code to validate the Username against the the list of valid users, but have not achieved this yet. Is there a command or template that you can suggest?

      Thanks

      Andy Sigrist

      Comment


        #18
        Re: Who is logged in?

        Originally posted by Sigrist View Post
        During testig of the new function I noted that a record is being created in Web_Log.Dbf regardless of whether the user entered a valid Username / Password or not.

        If a user enters a wrong Username or Password, the system does not log the user in, but a record is still added in Web_Log.Dbf. I tried to write Xbasic code to validate the Username against the the list of valid users, but have not achieved this yet. Is there a command or template that you can suggest?
        Andy,

        I'm not sure if there is a solution using your method or not, but usually we use a different methodology to register logins, namely running an interim xbasic page that fires after the user has logged in using the web security page setting pointing to an xbasic a5w page. The page only runs if the user successfully logs in (and also redirects to where you want the user to go).
        Peter
        AlphaBase Solutions, LLC

        [email protected]
        https://www.alphabasesolutions.com


        Comment


          #19
          Re: Who is logged in?

          There are a couple simple methods to capture who logged in. Peter mentioned one, which is to use the logging method. Another is similar to Steve's solution, but places the code differently. The source view of an a5w page that has a login component will have a section of code that runs the component, and then may redirect after login like this:
          Code:
          x_login = a5w_run_Component(tmpl_login)
          '=============================================================================================================
          if x_login.RedirectURL <> "" then
          The xxx.RedirectURL will only have a value if a login is successful. Therefore the if statement is only true after a successful login, so any code that should run after a login right can be placed after the last line above and before the actual redirect shown here:
          Code:
          	response.redirect(x_login.redirectURL)
          	end
          end if
          You don't need to check any values such as "submitbutton". You can still capture "userid" which is more accurately referenced as request.variables.userid, but a better solution is to use the function A5WS_Logged_In_User_Values() and capture the actual values accepted. Putting that alltogether, the result would be something like this:
          Code:
          if x_login.RedirectURL <> "" then 
          	dim pUser as p
          	a5ws_Logged_In_User_Values(pUser)
          	if pUser.Userid <> "" ' should always be true after a successful login
          		tbl = table.open("[PathAlias.ADB_Path]\Web_Log.dbf")
          		tbl.enter_begin()
          		tbl.Userlogin = pUser.Userid
          		tbl.Logindate = Date()
          		tbl.logintime = Time()
          		tbl.enter_end()
          		tbl.close()
          	end if 
          	response.redirect(x_login.redirectURL)
          	end
          end if
          Checking to see if pUser.Userid has a value isn't really necessary as it must after a successful login, but it is a good practice anyway.

          V11 has a new function named A5ws_GetCurrentUser() which returns the userid of the current logged in user.

          Comment


            #20
            Re: Who is logged in?

            Peter, Jerry,

            first, thank you for your replies and your help. I really appreciate it.

            Since I posted this question, I have found an alternate solution that appears to work (See attached picture of the fist part of my Login.A5W page). I use the following code to check for a valid UserID:

            DIM USERIDFLG as L
            USERIDLST = A5WS_Get_Users()
            USERIDFLG = *any(USERIDLST, userid)
            If USERIDFLG = .T.

            I will try your solution today as well.

            Andy

            UserID.jpg

            Comment


              #21
              Re: Who is logged in?

              I am trying to do something similar here, instead of creating a table and recording last login date and time. I am trying to open a SQL table and record the last login date and time in an existing field in the table. How would I modify the above code to achieve opening the sql table and recording this in a existing field?

              Comment


                #22
                Re: Who is logged in?

                Web Security allows you to create a function to capture relevant data. Look in security settings for Log File.

                Here is one I use:

                Code:
                function saveLoginLog as v (e as p)
                '-- Values Available - Data type - Description
                'e.session - Pointer - session variables. TIP: To set a session variable: e.Session.myNewSessionVariable = "Alpha"
                'e.userid - Character - userid of the logged in user
                'e.ulink - Character - 'ulink' value saved for the logged in user
                'e.passexp - Time - a time value indicating when the user's password will expire
                'e.loginexp - Time - a time value indicating when the login will expire
                'e.loginerror - Character - any error message returned from a login component if a login failed
                'e.IP - Character - IP address of the remote client making the request
                'e.logout - Logical - Default is .F., will be .T. if the action is a 'log out'
                ''===============================================================================
                Dim conn as SQL::connection
                Dim args as SQL::Arguments
                Dim SQL as c
                
                vHost = request.host
                vNow = now()
                
                If e.logout = .T.
                	vType = "LogOut"
                	vExpires = vNow 
                Else
                	vType = "LogIn"
                	vExpires = vNow + (session.timeout*60)
                End If
                
                args.add("LoginName",e.userid)
                args.add("DateTime",vNow)
                args.add("Type",vType)
                args.add("IP",e.IP)
                args.add("LogExpires",vExpires)
                args.add("PwdExpires",e.passexp)
                args.add("LogError",e.loginerror)
                args.add("Host",vHost)
                
                SQL = "INSERT INTO Login_Activity (LogLoginName, LogDateTime, LogType, LogIP, LogExpires, LogPwdExpires, LogError, LogHost) VALUES (:LoginName, :DateTime, :Type, :IP, :LogExpires, :PwdExpires, :LogError, :Host)"
                
                conn.open("::Name::System")							
                conn.execute(SQL, args)
                conn.close()
                
                end function
                Note: e.logout wasn't working for me thus the work-around.
                Peter
                AlphaBase Solutions, LLC

                [email protected]
                https://www.alphabasesolutions.com


                Comment


                  #23
                  Re: Who is logged in?

                  I think this is all completely overboard for what he needs to do - its pretty simple.
                  I think he just wants to display the username of who is logged in.

                  Assuming you are using the ulink field (which most applications will) - you can do a lookup from the websecurity fields. (note the following is for mysql, but it should be transferable to dbf, maybe a dbf guy can help you on this one) -anyhow
                  If youre not using ulink there is PROBABLY some a5ws_get_Guid function for the current user, and u can use that and hte guid field instead.

                  Code:
                  <%a5
                  dim args as SQL::Arguments
                  args.set("ulink",session.__protected__ulink)
                  dim email_logged_in as C=convert_type(sql_lookup("::name::conn","websecurity_users","ulink=:ulink","userid",args),"C")
                  ?"You are logged in as: "+email_logged_in
                  %>
                  This would display
                  You are logged in as: [email protected]

                  Is this what you needed?
                  If you need the users' first name and last name, then you need to create a web_user table or a person table or something else and link those based on ulink.

                  Then you can lookup based on that table and the ulink.

                  If you are willing to pay for 1 on 1 help, we could do a gotomeeting and take a look together.

                  Anyhow,
                  Goodluck!
                  Scott Moniz - Computer Programmer/Analyst
                  REA Inc.
                  http://reainc.net
                  (416)-533-3777
                  [email protected]

                  REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
                  If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
                  contact us to discuss options.

                  Comment


                    #24
                    Re: Who is logged in?

                    I have what I need working with this issue, wasnt sure if you replying to me or someone else.

                    Comment

                    Working...
                    X