Alpha DevCon 2018
Results 1 to 12 of 12

Thread: Users / web security / registered users / filtering lists on a logged in user

  1. #1
    Member joegrun4's Avatar
    Real Name
    Joe Grundmeyer
    Join Date
    Sep 2013
    Location
    Portlad, Oregon USA
    Posts
    108

    Default Users / web security / registered users / filtering lists on a logged in user

    Does anyone have detailed instructions or a link to a video on how to tie the web security stuff to another table emplyoyee table (for example). Or could someone send me a generic .a5wcmp file so i can pick through it and figure it out.

    Ultimately, I want to filter list controls based on the current logged in user. My list is looking in the employee table for the employeeId and filtering on this. That part works, now how do I have Alpha associate that employeeId with a user in the websecurityusers table?

    Any help on this topic is much appreciated. I have been reading through tons of stuff but cant figure it out. I feel like the info i keep reading is for old versions and i'm not sure if its valid on AA12.3... Im also NOT advanced so keeping the terminology understandable for a new Alpha user is key here.

    Thanks,

    -Joe G.
    Alpha Anywhere V12.4.1 Build 3594-4665
    Application Server V12.4.1 Build 3594-4665 Running on Windows Server 2008 R2 Standard 4GB Ram X3430 @ 2.40GHz
    MySQL 5.5.38

  2. #2
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,789

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    I think I can explain in simple text - in all of my applications I have the security framework, but also a local Users Table (called wt_users in my apps). That wt_users is tied to the security framework on Userid, which is their email address in my applications. I do not alter the security framework table ever. Then in your case I would add a field to my wt_users table for EmployeeID. That would tie wt_users to my employee table.

    Now when someone logs in, I get their login userid using a5ws_getcurrentuser() (or sometimes different methods), then I can get any value from either wt_users or employees using simple lookup functions. Then:

    dim empid as n = do a lookup to the wt_users table to get the empid
    dim empname as c = do a lookup to the employees table to get the employee name

    Lots of other methods to get the info.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    Member joegrun4's Avatar
    Real Name
    Joe Grundmeyer
    Join Date
    Sep 2013
    Location
    Portlad, Oregon USA
    Posts
    108

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    Thanks Steve. I will use what you have given me and try to apply it to my ux.

    I think a big issue for me is there always seems to be 10 ways to do everything in Alpha.
    Some of them are easy, some complex, some are dated for old versions, some are opinions that others say are bad practice, and some might as well be in Chinese because I just don't get it!
    Alpha Anywhere V12.4.1 Build 3594-4665
    Application Server V12.4.1 Build 3594-4665 Running on Windows Server 2008 R2 Standard 4GB Ram X3430 @ 2.40GHz
    MySQL 5.5.38

  4. #4
    Member joegrun4's Avatar
    Real Name
    Joe Grundmeyer
    Join Date
    Sep 2013
    Location
    Portlad, Oregon USA
    Posts
    108

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    That wt_users is tied to the security framework on Userid
    Steve,

    Could you explain this in detail a little further?
    Alpha Anywhere V12.4.1 Build 3594-4665
    Application Server V12.4.1 Build 3594-4665 Running on Windows Server 2008 R2 Standard 4GB Ram X3430 @ 2.40GHz
    MySQL 5.5.38

  5. #5
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,789

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    "tied" just means that security framework, specifically the websecurity_users table, and my wt_users table both have a field named USERID that contains the value used to login, known also as the username. So the USERID value Steve Wood in both security framework and wt_users is "steve@alphatogo.com". When I login, the value of a5ws_getcurrentuser() is also steve@alphatogo.com, so I can use lookup to get anything I want from security framework or wt_users based on that USERID value.

    How I keep those values in sync, so that security framework and wt_users value for USERID is always in sync, is another matter. I don't mean to turn this in to a plug, but I use my own Framework to always keep USERID in sync from Registration on, including if the user goes to MyAccount and changes their USERID.

    The reason I have a wt_users table is because Alpha repeatedly says not to mess with their security framework tables. If that were not the case, I would just add fields to security framework (the websecurity_users table) for firstname, lastname, etc. But since I am told not to mess with those, I have my own wt_users table with those custom values.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  6. #6
    Member joegrun4's Avatar
    Real Name
    Joe Grundmeyer
    Join Date
    Sep 2013
    Location
    Portlad, Oregon USA
    Posts
    108

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    In my case, the Userid in the websecurityusers (Alphas Security Framework) table is an email address like yours.

    I did not have a Userid field in the employee table. I do, however, already have an Email field in the employee table. I created a Userid in the employee table. Now, the Userid and the Email field are going to contain the same data. Im sure this is ok. Do I have one control populate the other with identical data? Or do I "tie" the employee.Email field to the websecurityusers.Userid field? Is it necessary that the field name be identical in both tables?
    Alpha Anywhere V12.4.1 Build 3594-4665
    Application Server V12.4.1 Build 3594-4665 Running on Windows Server 2008 R2 Standard 4GB Ram X3430 @ 2.40GHz
    MySQL 5.5.38

  7. #7
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    are you using dbf for security or sql?
    when you login the user name is available, as you have indicated it is an email address.
    now on the employee table you should have employee_id which is an autoincrement int ( that's what I use ) and an email address field which will contain the same email address as in the login part.
    now in dbf to get the employee_id you use
    employee_id = lookup("your_user_table","email_address='user_name_from_login'","employee_id")
    look at the single quotes inside the double quotes!
    in sql
    open connection etc.,
    SELECT id FROM your employee_table WHERE email_address = user_name_from_login

    that will give you the employee_id
    then you do whatever you want to do with that.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  8. #8
    Member joegrun4's Avatar
    Real Name
    Joe Grundmeyer
    Join Date
    Sep 2013
    Location
    Portlad, Oregon USA
    Posts
    108

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    Steve I guess im still stuck at "so I can use lookup to get anything I want from security framework or wt_users based on that USERID value"

    It makes sense in my head but again I don't know how to put it into effect... Where do you define this "lookup"? Can you provide an example?

    Gandhi, I am using MySQL. I don't know how to define the WHERE clause. I have tried several things with no luck.
    Alpha Anywhere V12.4.1 Build 3594-4665
    Application Server V12.4.1 Build 3594-4665 Running on Windows Server 2008 R2 Standard 4GB Ram X3430 @ 2.40GHz
    MySQL 5.5.38

  9. #9
    Member joegrun4's Avatar
    Real Name
    Joe Grundmeyer
    Join Date
    Sep 2013
    Location
    Portlad, Oregon USA
    Posts
    108

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    Capture.JPGCapture2.JPG
    ok so here is exactly what I have. How do I filter MYJOBSLIST with CurUser? Again, It is a MySQL database.
    Last edited by joegrun4; 02-06-2015 at 04:06 AM. Reason: swapped picture
    Alpha Anywhere V12.4.1 Build 3594-4665
    Application Server V12.4.1 Build 3594-4665 Running on Windows Server 2008 R2 Standard 4GB Ram X3430 @ 2.40GHz
    MySQL 5.5.38

  10. #10
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    I do not know how panels work.
    I do this in my mobile version
    in the first page I have master list then the link selects particular item with detail in the next page they are connected and it is a single page application ( which in my opinion is the panel in alpha)
    to do the where clause use it in your select statement
    SELECT jobs FROM job_table WEHRE employee_id = :newEmployee
    args.set ("newEmployee", the current user name)
    cn.execute (sqlSelect,args)
    then you can assign the result set to it.
    as I said I do not know how panel work I cannot help there
    I am sure steve will.
    Last edited by GGandhi; 02-06-2015 at 06:46 AM.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  11. #11
    Member bob9145's Avatar
    Real Name
    Bob Senski
    Join Date
    Jun 2009
    Posts
    744

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    In a UX isn't this now all doable in the onlogin server side event using e.userNameFriendly, or e.username? I watched the 5 videos UX_V12-65, and experimented with the logincomponentmobilapp template that gets you to retrieving the user ID through the onlogin event. It would be helpful if the videos went one step further and provided a full example that retrieves an Id that is then used to filter related records in a list control of an embedded UX like the one shown in the videos.

    Here's the scenario:
    1)Sequel tables: salespersontbl, cusatomertbl, salesperson_has_customertbl.
    2)Salesperson logs in username matches their email within the salespersontbl through a lookup the SP-Id is retrieved
    3)The SP-Id is used in a second lookup to retrieve the related records within salesperson_has_customertbl
    4) These matching records are retrieved from customertbl
    5) The result set is used to populate a list control within a UX embedded in the login template component.

    Extra credit: update, add, or delete a record from the list control in the customertbl, and salesperson_has_customertbl

    This would bring filtering, adding, and updating linked records in linked table based on the logged in user into the future along with self driving google cars!
    Bob

  12. #12
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    330

    Default Re: Users / web security / registered users / filtering lists on a logged in user

    Joe,
    I have only just this week solved the filtering issue with a logged in user, so I recognize your situation. I understand what is written in this post and have been watching videos on the subject.
    All very good advice but I needed and example of how and where. With the bits and pieces I found, I finally managed to get things going the way I wanted.

    I will try to give you an example of how I have done things.
    Using latest build of Alpha Anywhere and MYSQL.
    Created a Tabbed UI page with integrated Login.
    Mainpage.png
    This example has two frames because of different access rights of certain grid components.
    Which frame is to be displayed is configured in Security Groups.
    In this example the focus is on Frame 1 that is displayed when a coordinator is logged in.
    The situation is that I have a table with employees from a certain company with several business units.
    Each business unit has a coordinator, responsible for the employees in that unit.
    A coordinator is only allowed access to employees in his/her business unit.
    The coordinator details are stored in a table named "coordinator". (Comparable with wt_users as mentioned by Steve Wood.)
    Under Web Security the user accounts are defined and assigned to a group "Coordinators".
    Example is user "KON561".
    In the coordinator table he is registered as Userid "KON561" and Contactname "Fred Olsen"
    In order to being able to filter employees from business unit "561" a Server-Side Event onLogin is created on the Tabbed UI page.
    onLogin.png
    After successful Log in "session.var1" contains "561". This session variable can be used to Link the required employee records as shown in the first image under Link properties.

    In my example each grid is a standard grid, showing all records. So you don't have to build a new grid but just apply the Link CON-ID (C)=session.var1.

    Hope this example helps you in finding your way.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

Similar Threads

  1. User Security - making group changes on other users
    By mstricky in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 05-09-2014, 10:38 AM
  2. Setting filters from Registered users info
    By MRall in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 04-25-2013, 11:16 AM
  3. Retrieve web security users
    By eskimoavenue in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 10-04-2011, 12:14 PM
  4. Filtering Web Users
    By mstricky in forum Application Server Version 8
    Replies: 0
    Last Post: 01-26-2008, 01:01 PM
  5. Email confirmation of newly registered users
    By Steve Wood in forum Application Server Version 8
    Replies: 3
    Last Post: 06-14-2007, 05:21 AM

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
  •