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

Login redirect by user type

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

    Login redirect by user type

    I have created the login dialog and successfully log in and have been redirected to the proper form(a5w) that I wanted it to go to. But now I need to direct the logged on user, to 1 of 2 forms based upon their user type (I = internal & C = customer). I cannot seem to get a grip on the DLG-Login Dialog Component sample.

    I think this is because of the conventions of xbasic and my unfamilarity with this code (many years of using vb and vba).

    Basicly the code has to validate user name, password and get the user type.
    The type then redirects the authenticated user to a specific target page.

    Any thoughts or suggestions?

    #2
    Re: Login redirect by user type

    In the "after validate", simply place an if statement to direct to appropriate page. In fact I think there is an example of this displayed on the AV page.

    Comment


      #3
      Re: Login redirect by user type

      Rick,

      You'd have aftervalidate statements similar to the following:

      level = lookup("<ADB_Path>\customers.dbf,"customerID="+quote(session.username),"Level")
      session.__protected__securitylevel = Level

      .....

      select
      case level = 1
      response.redirect("thispage.a5w")
      case level = 2
      response.redirect("thatpage.a5w")
      case else
      response.redirect("defaultpage.a5w")
      end select

      Elsewhere in your application you would refer to the level by the session.__protected__securitylevel variable. Those are special vars that the user can not maliciously set via a URL.
      Steve Wood
      See my profile on IADN

      Comment


        #4
        Re: Login redirect by user type

        Thanks,
        I will try these suggestions today and advise results.

        Comment


          #5
          Re: Login redirect by user type

          Rick

          First you have to Validate the session variable;

          session.type=lookup("[PathAlias.ADB_Path]\user_names","user_name=" + quote(user_name),"Type")

          Then as Steve says in the Aftervalidate you direct the user, in my case I used the following:

          if session.type="A"
          response.redirect("Admin.a5w")
          else if session.type="T"
          response.redirect("Teachers.a5w")
          else if session.type="S"
          response.redirect("Students.a5w")
          else if eval_valid("session.targetUrl") then
          if session.targetURL <> "" then
          Currentform.RedirectTarget = session.targetURL
          end if
          end if

          I hope this helps you as it did me.
          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


            #6
            Re: Login redirect by user type

            Working on it right now. I'll give it a try
            Thanks for your input

            Comment


              #7
              Re: Login redirect by user type

              Both redirect senerios worked. The problem I encountered was that
              although it appeared that the code was running, I never left the login page.

              It turns out that I was being redirected, by the page header statement in the requested pages (<A5 a5w_include("logintest.a5w") %> ) back to the login. Once these statements were removed everything went OK.

              Now I need ti fix the logintest statements.

              Comment


                #8
                Re: Login redirect by user type

                Logintest.a5w checks to see if a variable is True that the person is properly logged in. A typical logintest.a5w looks like this:

                <%a5
                session.targetURL = request.request_uri
                if eval_valid("session.__protected__IsLoggedOn") = .f. then
                response.redirect("login.a5w")
                end
                end if
                %>

                Note that it is testing for session.__protected__IsLoggedOn. If you are not properly setting that value in the event code for your login dialog, then it will always be False, and the logintest code will pass the user back to the login page.
                Steve Wood
                See my profile on IADN

                Comment


                  #9
                  Re: Login redirect by user type

                  I do appreciate your feedback on this.
                  I set up my before and after events based upon that data provided in the "How the login feature works".

                  Here's my validate:
                  'look for blank entry in user name or password & return error message
                  if User_Name = "" .or. Password = "" then
                  CurrentForm.Has_Error = .t.
                  CurrentForm.Error_Message = "&nbsp; Error0: User name or password cannot be blank."
                  else
                  'Validate user name and password
                  Dim Correct_Password as C
                  Dim Correct_Type as C
                  Correct_Password = Lookup("<ADB_Path>\User_Names", "User_Name=" + quote(User_Name),"Password")
                  If Correct_Password <> Password then
                  CurrentForm.Has_Error = .t.
                  CurrentForm.Error_Message = "&nbsp; Error1: Invalid User name or Password."
                  End If
                  'Get session type
                  Correct_Type = Lookup("<ADB_Path>\User_Names", "User_Name=" + quote(User_Name),"Type")
                  end if

                  And here's my after validate:

                  If Eval_Valid("correct_type") then
                  if correct_type = "C"
                  currentform.redirecttarget = "Survey.a5w"
                  else if correct_type = "I"
                  currentform.redirecttarget = "Surveyview.a5w"
                  end if
                  end if

                  My logintest is:

                  <%A5
                  If eval_Valid("session.FlagIsLoggedIn") = .f. then
                  session.targetURL = request.request_uri
                  response.redirect("login.a5w")
                  end
                  end if
                  %>

                  So I see from your reply that my logintest needs changing..but I'm uncertain about what is need in the validate event for the session._protect-IsLoggon

                  Comment


                    #10
                    Re: Login redirect by user type

                    So that's it then. You are testing for "session.FlagIsLoggedIn" in logintest, but not setting it to TRUE anywhere in the login events. Just add the following as the first line in your aftervalidate for login.


                    session.FlagIsLoggedIn = .t.
                    Steve Wood
                    See my profile on IADN

                    Comment


                      #11
                      Re: Login redirect by user type

                      Thanks Steve, That did the trick.

                      Comment


                        #12
                        Re: Login redirect by user type

                        Hi All

                        Once again probably a stupid question form me, But have used your above example to get my users to redirect to their own pages, I however wish to stop say a level one user jumping to a level 2 page if he finds out the url.

                        What code can I use to acomplish this and where would I put it.

                        Any help will be once again appreciated

                        Thanks

                        John

                        Comment


                          #13
                          Re: Login redirect by user type

                          If you look at the logintest.a5w you see that it redirects users back to the login page if they are not logged in. This process looks to see if the value to session.Is_logged_In (or whatever your variable is named) is True. You can use the same logic to return a user to the login page if the open a page above their security level. For example, in a Level2 page, put a5w_include("mustblevel2.a5w") and have the mustblevel2.a5w page contain code similar to logintest.a5w that tests if their security level is level 2. If not, redirect them to the login page with a nasty note about trying to access pages without authorization.

                          You can also log the attempt by sending yourself an email in the mustblevel2.a5w. If they are not level 2 or above, send them to the login page, and also send youself an email.
                          Steve Wood
                          See my profile on IADN

                          Comment

                          Working...
                          X