How to arrange Database to allow for sub-users - database

Im looking to make a web app dashboard where there is a main user then inside there are staff/sub users that can switch to their accounts
how would ago about this?
Example
Main Staff accounts(Admins) ---> SUB-Users
Have done research but I can't find a final answer for the backend, how the database would look.
TO clarify.
EXAMPLE
LOGIN TO MAIN COMPANY ACCOUNT(MANAGER)
IT THEN HAS OPTION TO SWITCH PROFILES INSIDE TO STAFF (SUB ACCOUNTS)

Related

Normal user (not admin) registration and publishing in Wagtail

I understand Wagtail is a CMS. Per my test so far, only the admin has permission to publish an article/content. I checked out "puput" and a few others as listed here. I wonder is there a way to allow normal user registration, login, publishing? Something similar to Medium, where the normal user, or say the community, can contribute to the content generation.
I thought there might be a toggle or switch to enable this. But I didn't find it. I'm looking for a way that is either a package or a plugin or similar. Not coding from scratch. Ideally within Wagtail CMS, but other frameworks based on Django should also be fine.
Thanks.
Wagtail provides two user groups:
Editors: user within this group can create page and submit it to moderation
Moderators: user within this group can publish pages that have been submitted to moderation.
To update groups for a given user, go the the django admin interface with admin credentails, usually the url is your-domain/admin
Then go to Users under Authentication and Authorization category
Then get into the user you want to allow posting pages,
Scroll down until Permissions category and moove groups Editors and Moderators from Available groups to Chosen groups as follow:
Then save new settings.

How to activate company accounts through email after creating the company. RAILS

so this is my first question here in stackoverflow, i always find the answer by looking here... so.
I have this issue, I have a Model named Company, which can have many users, which would be the "best approach" to create and activate a user account within this newly created Company.
Here is the process i am following:
Platform Admin creates a company, the company serves as a grouping account in which i will have a number of users, but i need to send an Email after company creation to the Company admin in order to have him create his account so that he can manage the other company users, this email needs to have a hash so that it has some kind of reference to the company (avoiding the company selection in the form).
Im using Rails 4.2.6 and Angular 1.5
so im stuck after the company creation form.
In an email send the angular route url which got the company hash that just created. When admin user clicks on that link your angular route gets called and then before it render the view , i mean use resolve in angularjs route, get the list of all the user and company that just got created where admin user can select user that he or she want to activate.

How to (approach) building user profiles / areas

**edit: I realise this is a somewhat general post, I am merely looking for some guidance, examples etc.
I have just set out with the goal of (self)learning some deeper web development and have started with Angularjs. I have realised that I learn better when building towards a set project.
With that in mind, I set out to build a relatively simple web app where by users (mainly aimed at Professional chefs) can log in, access their profiles /user area. Users can then add items to a food ingredient database which may include variables such as weight, quantity,price etc. They can then add recipes, drawing from the ingredient database, with the app returning their food cost, tax breakdown as well other predefined calculations.
I have already built the bare bones of the application with Angularjs handling He various front end routes and layout.
I have wired the app to use Firebase for the purposes of User authentication and registration components.
As I mentioned, I am mostly self learning and I'd like some pointers on how to implement a user profile area with Angularjs, using Firebase as the back-end database.
I'd like to achieve the following:
after user login, direct to a user specific page
The user page/area should have abilities such as: profile photo upload, change email, change password etc (usual user operations)
Once the above is achieved:
seperate pages where users can add to their database of ingredients
seperate page where users can create recipes utilising database items, returning cost breakdown etc.
The user operations page / area is my main concern for the moment.
Thanks in advance.

Scope/Group/Role/Permissions database architecture

I'm building an internal web app and struggling with some DB design theory.
I've already got roles & permissions set up with Laravel & Entrust, but i'm trying to add extra functionality of Scopes and Groups and i'm not quite sure how to achieve it.
Given the following scopes:
Company
Team
and these roles:
Admin
Editor
Author
and these groups(teams):
Sales
Development
Design
I've already added scopes functionality which works great, so I can have a permission assigned to an admin in the company scope, but I want to be able to assign permissions to admins in a team scope according to the team they belong to.
The application will be quite expansive, but to keep it simple here i'll focus on a couple of use cases that I need to satisfy: Team and employee profiles.
Team profiles
All employees can view all team profiles
A company admin can edit all team profiles
A team admin can edit their own team profile
Employee profiles
All employees can view all employee profiles
A company admin can edit all employee profiles
A team admin can edit employee profiles within their own team
An employee can edit their own profile
What's the best way to achieve this? Every time i try and approach it the solution feels overly complex and i bury myself in nested foreach loops. Is that just the bed i've made for myself or is there a better way to check for a permission against a role, scope & group at the same time?

Patterns for replicating user data from one software to another

I have a website that I've integrated with a popular forum software (phpBB).
I have it setup so users that login to the main site automatically are logged in to the forum software as well. I do this by authenticating through the forum's API at the very same time.
When someone registers for the site, an entry goes in to the main site database and an entry goes in to the forum user database (using the forum API).
The primary id of the forum user table is stored in a column in the main site user DB. This is saved at the time of registration: the registration process first creates a forum user, then passes back the ID in to the query that creates the user in the main site.
When a user logs in, if they authenticate with the main site, that ID is pulled and passed in to the forum login API to login the correct person.
However, a weird thing seems to happen randomly: one in every 30 or 40 people that registers ends up with a forum user id that is not their own in the main site user table. I know how to look for these problems and fix them on case by case basis and have scripts in place to do so, but that seems like more of a bandaid, not a fix.
Is this a common problem when linking data like this, or does this seem like something more specific with the software? Because of the randomness of this issue its been hard to debug.
I would suspect Session Management. Are you intentionally or unintentionally reusing session ids?
I've done something similar with vbulletin, by directly using the forum's mysql database to autheticate the main site, and other sites (they're all on the same machine)...
In your case, I would add the site-specific fields that are not in phpBB database in the site's db, and link it to phpbb by user_id... It could be one form on the main sites that inserts into the two databases (some in the main site db, others in phpBB db - with some more privileges fields), I'd use my own non-standard captcha like generating a distorted image "what is x+y" with x and y as random numbers and + may be replaced by other operations, or an image of "type the word ORANGE", or "type your username again"
I would disable the default phpBB registration... there are so many bots that know how to use it...
This would guarantee you have one source for the info, and you fill all the info at once.

Resources