SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Handling Different Types of Users

    I'm in the process of building an e-commerce site. (For anyone who has been on SitePoint in the past 20 years, you will realize it's not going very fast!!)

    What is the best way to group and label different types of people?

    Original Plan:

    User (super-class/table)
    - Visitor (sub-class/table)(unregistered)
    - Customer (sub-class/table)(registered)
    - Admin (sub-class/table)(registered super user)



    Points of Contention:

    1.) Have One Class/Table called "User" - it will be a pain to have to manage sub-classes/tables and move people around as they change roles.

    2.) Create a separate Role-Class/Table - this will allow you to much more easily manage User-Roles and promote/demote people on the fly.

    3.) What is a 'Customer'? - I say it is anyone who is shopping regardless of whether they are a Returning Customer or a New Customer. (Try telling your boss that the people waiting outside to try your world famous <whatever> are not yet 'Customers'?!)

    4.) How much to track from "Visitors"? - Is it physically possible or desirable to save a "Visitor's" (i.e. no Customer Account yet) shopping cart in the back-end database and then somehow match that shopping cart back up with them when they return if they haven't registered yet?!

    Also, I think writing what "Visitors" do on the backend would be helpful as far as metrics go. if they don't register and buy something in 30 days, delete the records but keep the shopping-patterns data for reporting and future planning.

    What do you think?



    TomTees

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    you won't have to move users around if the role is kept separate from the user who has the role

    and what if a user has more than one role?

    ask yourself what would have to change about your proposed table design if you did not use those three "sub-class" tables
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    you won't have to move users around if the role is kept separate from the user who has the role

    and what if a user has more than one role?

    ask yourself what would have to change about your proposed table design if you did not use those three "sub-class" tables
    If one User had one Role, it would just be adding a UserRole field.

    If one User could have many Roles, then it would be a many-to-many

    User -||-------<-UserRoleDetails->-------||- UserRole

    (Crow's Foot Notation for all of the "cool" people here...)



    TomTees

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might help visualise possible solutions if you post the actual role names. Then it should be easier to offer solutions on how to best structure them in the database.

  5. #5
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kalon View Post
    It might help visualise possible solutions if you post the actual role names. Then it should be easier to offer solutions on how to best structure them in the database.
    See my original post.


    TomTees

  6. #6
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, I am assuming a user will be assigned only 1 role.

    If that is the case you could have just 1 user table. One of the columns in that user table could be called fldAccessLevel where access level 1 = admin, 2 = registered customer.

    Then every time a request is made for a web page from a client browser, you check if the user is logged an the time, and if so what the current session access level is set to. If is 1, the user can see any web page. If it is 2, then the user can see all the web pages except those that require a fldAccessLevel = 1 (admin web pages). If no session access level is currently set, then the user is not logged in and so can view only the public web pages.

  7. #7
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kalon View Post
    ok, I am assuming a user will be assigned only 1 role.
    I slept on it, and you are correct, and others were leading me astray.

    One User, One Role. (If an "Admin" also wants to be a "Customer", then he/she will have two accounts!!)


    If that is the case you could have just 1 user table. One of the columns in that user table could be called fldAccessLevel where access level 1 = admin, 2 = registered customer.

    Then every time a request is made for a web page from a client browser, you check if the user is logged an the time, and if so what the current session access level is set to. If is 1, the user can see any web page. If it is 2, then the user can see all the web pages except those that require a fldAccessLevel = 1 (admin web pages). If no session access level is currently set, then the user is not logged in and so can view only the public web pages.
    I have a question about this, but it relates to PHP and OOP...

    Can I ask it here or should I start a new thread?



    TomTees

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by TomTees View Post
    One User, One Role. (If an "Admin" also wants to be a "Customer", then he/she will have two accounts!!)
    i think this is suboptimal, but hey, it's your design...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    i think this is suboptimal, but hey, it's your design...
    Why do you say that?

    Please explain!


    TomTees

  10. #10
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    explain? i should think it was obvious

    how would you feel if you had to sign on to sitepoint with two different userids, depending on whether you were posting a new thread or answering an existing one

    p.i.t.a. (and i don't mean People Ingesting Tasty Animals)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  11. #11
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Tom say you make this site, in 6 months you want to buy from it, will you easily know which name is the admin and which you can use to buy?... then think of Rudy's comment
    Ryan B | My Blog | Twitter

  12. #12
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    explain? i should think it was obvious

    how would you feel if you had to sign on to sitepoint with two different userids, depending on whether you were posting a new thread or answering an existing one

    p.i.t.a. (and i don't mean People Ingesting Tasty Animals)
    Hello...

    Would I expect that you have to log on using an Admin ID to be able to change content and features on SitePoint and a separate Member ID to just be able to make a simple post on SitePoint??

    YES!!



    TomTees

  13. #13
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    Tom say you make this site, in 6 months you want to buy from it, will you easily know which name is the admin and which you can use to buy?... then think of Rudy's comment
    I would expect Admin accounts for any website are set up differently enough that you could never confuse them.

    That and the fact that you won't have 500 Admin accounts.

    More so, I would expect that *if* you have an Admin account, you are only using it on the back-end and have an entirely different entry point into the site.

    No Admin would go to www.amazon.com, log in as a *super user*, and then start changing the website from the public-facing website?!

    They would presumably log in to a Development/Staging/Production Back-End Environment.

    In fact, good security would prohibit a *super user* from logging in as a regular user from the outside web...


    TomTees

  14. #14
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TomTees View Post
    I would expect Admin accounts for any website are set up differently enough that you could never confuse them.

    That and the fact that you won't have 500 Admin accounts.

    More so, I would expect that *if* you have an Admin account, you are only using it on the back-end and have an entirely different entry point into the site.

    No Admin would go to www.amazon.com, log in as a *super user*, and then start changing the website from the public-facing website?!

    They would presumably log in to a Development/Staging/Production Back-End Environment.

    In fact, good security would prohibit a *super user* from logging in as a regular user from the outside web...


    TomTees
    I was talking about the admin himself, I wouldn't hope you wouldn't suggest something like rguy84 is my user name and my admin name is rguy84_admin...
    Ryan B | My Blog | Twitter

  15. #15
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,813
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by TomTees View Post
    More so, I would expect that *if* you have an Admin account, you are only using it on the back-end and have an entirely different entry point into the site.

    No Admin would go to www.amazon.com, log in as a *super user*, and then start changing the website from the public-facing website?!

    In fact, good security would prohibit a *super user* from logging in as a regular user from the outside web...
    When is it you propose that this complete change of the way just about all systems work be implemented so as to take away the single account that some people currently have that needs to be replaced by two, three, or more accounts under your new approach?

    How many people do you think will want admin etc accounts if they have to log out of their normal account and log back in via a different account to use it - probably not many in which case most sites requiring logins will then disappear because there is no one to administer it.

    For example the backend of vBulletin assigns everyone a main role and then has checkboxes to attach all the other roles that are available on that one login. If I had to have two accounts here - one to make normal posts and one for moderating the forum then the moderator login would never get used.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  16. #16
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    I was talking about the admin himself, I wouldn't hope you wouldn't suggest something like rguy84 is my user name and my admin name is rguy84_admin...
    If this site ever gets built, it will be a ma-and-pa shop, so all of this would be a non-issue.

    I don't know how Amazon or SitePoint handles this issue.

    However, I can say with a high degree of certainty, that "Admin" accounts are intuitively different to anyone using them than a "User" account.

    They usually lead to different areas, different screen, and have entirely different log in steps.

    I would never allow an "Admin" to log in and shop from the main page of my website. Never!!

    In fact, I would probably have a security rule stating that you cannot log in and shop from the main page of the website.

    If you allow that, then what happens when "Joe Super Admin" logs in to his "Super Admin Account" at the public library so he can buy a DVD, and then he gets distracted by a pretty girl and walks off without logging out?!

    Isn't all of this pretty obvious??

    Yes, One Person can have multiple Account Types, but only One User Account can only have One Set of Security Rights.

    You want "Admin" accounts to be segregated from "User" accounts on many levels...



    TomTees

  17. #17
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,813
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by TomTees View Post
    You want "Admin" accounts to be segregated from "User" accounts on many levels...
    Most systems handle that by requiring someone with an admin account to enter their password a second time when requesting access to the admin only functionality.

    So when "Joe Super Admin" logs in to his "Super Admin Account" at the public library so he can buy a DVD, and then he gets distracted by a pretty girl and walks off without logging out anyone who does access it can only access the regular user functionality because to access the back end requires entering the password again (unless Joe was in the backend when he forgot to log out).

    The general rule is that whenever someone tries to access a more restricted area of the site that they must enter their password again so that if someone did forget to logout that access is limited to whatever part of the site they were logged into at that time.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  18. #18
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    When is it you propose that this complete change of the way just about all systems work be implemented so as to take away the single account that some people currently have that needs to be replaced by two, three, or more accounts under your new approach?

    How many people do you think will want admin etc accounts if they have to log out of their normal account and log back in via a different account to use it - probably not many in which case most sites requiring logins will then disappear because there is no one to administer it.

    For example the backend of vBulletin assigns everyone a main role and then has checkboxes to attach all the other roles that are available on that one login. If I had to have two accounts here - one to make normal posts and one for moderating the forum then the moderator login would never get used.
    Moderating Forums is a little different than "root" access to the entire website.

    I bet you couldn't log in as a "Super Admin" to Amazon.com from the Web. You would probably be required to log in at the very least to a VPN, if not physically from a computer on-site.

    Is my website at that level? Of course not. But early I got a strange look for saying One User Account has One Security Role.

    Why would anyone want to shop on an E-commerce site for personal reasons, away from work, and to also expect to be able to have the rights to bring the entire site to a screeching halt in a few keystrokes?!


    TomTees

  19. #19
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Most systems handle that by requiring someone with an admin account to enter their password a second time when requesting access to the admin only functionality.

    So when "Joe Super Admin" logs in to his "Super Admin Account" at the public library so he can buy a DVD, and then he gets distracted by a pretty girl and walks off without logging out anyone who does access it can only access the regular user functionality because to access the back end requires entering the password again (unless Joe was in the backend when he forgot to log out).

    The general rule is that whenever someone tries to access a more restricted area of the site that they must enter their password again so that if someone did forget to logout that access is limited to whatever part of the site they were logged into at that time.
    It's a continuum, but I come back to the main question, which is, "Why would a Super Admin need or want to Shop (minus for testing purposes)?!"

    It depends on the size of the system, what is at risk, and numerous other factors.

    But in the business world I've usually seen things segregated pretty clearly like I'm describing.

    "Admins" have no reason or right to be shopping on a web-facing e-commerce site. Their role and purpose is on the backend which is protected in many ways (VPNs, Firewalls, Physical Security).

    You could never get PCI Compliance (or any other type of security certification) by allowing "Root" users to be accessing mission-critical systems from the outside via the Internet. Never!!

    Does this apply to my website or future business? Not as much so.

    I just chose the design for simplicity!

    If you run a usergroup for your favorite sports team, is what you are proposing good enough? Probably so.

    But if that is how lax Sitepoint is - beyond simple "Forum Admins" - then I'd be really shocked!

    An interesting debate nonetheless!



    TomTees

  20. #20
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TomTees View Post
    Moderating Forums is a little different than "root" access to the entire website.

    I bet you couldn't log in as a "Super Admin" to Amazon.com from the Web. You would probably be required to log in at the very least to a VPN, if not physically from a computer on-site.

    Is my website at that level? Of course not. But early I got a strange look for saying One User Account has One Security Role.

    Why would anyone want to shop on an E-commerce site for personal reasons, away from work, and to also expect to be able to have the rights to bring the entire site to a screeching halt in a few keystrokes?!


    TomTees
    When I developed for my very large university (45k+ students), I could not go to www.uni.edu/admin and there was the world. I have to log in via kernal, or sftp program.... I had 1 username for my three roles: student, staff, developer.
    Ryan B | My Blog | Twitter

  21. #21
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TomTees View Post
    "Admins" have no reason or right to be shopping on a web-facing e-commerce site. Their role and purpose is on the backend which is protected in many ways (VPNs, Firewalls, Physical Security).
    If you want users to access just the web pages their access level allows and not also the web pages of any subordinate role then that is fairly easy to set up as well.

    At the top of each page you could have

    Code:
     
    if(!isset($_SESSION['access_level']) || $_SESSION['access_level']) != 1) {
       echo 'you are not an authorised user';
       die();
    }
    You set the check value of $_SESSION['access_level'] in the 1st line to the appropriate role/access level for that web page.

  22. #22
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by TomTees View Post
    YES!!
    actually, no
    Quote Originally Posted by TomTees;
    In fact, good security would prohibit a *super user* from logging in as a regular user from the outside web...
    i think you are making up rules here, because "good security" says no such thing
    Quote Originally Posted by TomTees;
    I would never allow an "Admin" to log in and shop from the main page of my website. Never!!
    well, like i said a whole bunch of posts ago, it's your system, so you are free to do it the way you want...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  23. #23
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why are we debating security when that wasn't even the point of my original post??

    Nice side discussion, but not what I set out to discuss.



    TomTees


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
  •