About Users
This article provides comprehensive information on implementing users in your Knack app and effectively managing them.
What You'll Learn
You'll discover how to activate and manage users in your Knack app, understand the different user settings available, and learn how to implement user functionality to create a secure, personalized experience for your app's users.
What are users?
Users are people who can log into your app using an email and password. By default, anyone with your app's URL can access it. When you enable user accounts, you can:
- Require logins to view content
- Set up different permission levels
- Let users see only their own records
Knack offers user and login functionality, allowing you to enforce login requirements for your live app users, establish roles and permissions, and restrict access for logged-in users to their own records.
By default, any Knack app is accessible to anyone with the URL. However, by enabling users and logins, you can require users to log in before they can access the app, for pages you don't want to be publicly accessible.
Activating Users
To activate user and login features, select the User Logins section while viewing the App Settings from the left side menu. In the User Logins section, select the "Activate Users" button.
Note: You can also activate users by selecting "Enable Users" under the User Roles section of your Tables list.
While activating users from the app settings, you will have the option to choose which type of login you want to use with your app:
-
Secure individual pages with a login will allow you to have different types of users and choose which pages will have logins. (This is the preferred option.)
-
Secure every page with the same login will only allow you to add one login to your app for only one type of user. (Less flexible)
-
Do not require a login to access your application will allow anyone with the URL to access your app. (This is not recommended. You can remove login pages individually to create public access.)
Caution: Login settings are foundational to your app's structure. Changing this selection after you have set up pages with logins will cause unrecoverable breaking changes.
If you want to test out a different setting, please do so in an app copy.
Tip: Most app use cases require user roles such as Employees, Supervisors, Teachers, and Students. To allow different roles to access different parts of your app, it is important to select the default option which enables logins for different pages and user roles.
You can learn more on managing user and login features and security settings available after user logins have been enabled.
Managing User Accounts
Creating User Roles
When you activate users, Knack creates an Accounts table that tracks everyone who can log in. Every user who can log in to your app using an email and password will have their own individual record stored in the Accounts table.
You can also create specific roles like:
- Employees
- Supervisors
- Students
- Teachers
These different types of user "types" will allow you to customize their permissions in the Live App.
To add a role, click "+" next to User Roles in the Data section.
Adding Users
You can add users in several ways:
- Manually in the Builder
- Import from spreadsheets
- Through registration forms
- Via Live App forms
To add a new user manually, navigate to the Records section of the Builder and click on the "+ Add Record" button. User roles function the same as regular tables in your database.
Note: Similar to other tables, these user records can also be added with a form element from the Live App.
Editing User Roles
To edit user roles, you have the option to click on the settings icon next to the user role name.
In the user role settings, you can edit the following options:
- Table Name: This represents the name of the user role.
- Display Field: This field will be the visible representation of the record in connection fields.
- Sort Order: This represents the default order in which records will be sorted within the user role.
- Approval Template: This is the editable email template used to notify users that their accounts have been approved.
- Account Info Template: This is the customizable email template used to send users their account information.
Editing User Records
You have the ability to edit individual user records in both the Builder and the Live App.
Editing Users in the Builder
To edit user records in the Builder, simply navigate to the Records section and locate the user role you want to edit. From there, you can easily make changes by clicking on the edit icon next to the specific record.
Selecting the pen icon next to the record will open a form in a modal popup where you can modify the user record. Alternatively, you can also edit the record directly by selecting a specific cell on the record itself and inline-edit.
Editing Users in the Live App
You also have the option to edit user records directly from the Live App by utilizing an edit form element, which functions similarly to records in other tables.
Deleting User Roles
To delete a user role, click on the more options icon next to the user role name. Then, choose the "Delete" option. This will delete the user role but will not delete the user records in that role.
Those user records will remain in the main Accounts table without that role.
Caution: A user role, similar to tables, is a foundational part of your app. Deleting a user role may corrupt pages, elements, and connections that use this user role.
Deleting User Records from the Builder
To delete user records, navigate to the Records section in the Builder. From there, you can simply use the checkboxes to select the specific records you want to delete.
Once the records are selected, new options will appear, allowing you to choose the "Delete" option.
Tip: If you are looking to restrict access but would like to keep the user record for historical reference, you can set the User Status field value to "inactive" to prevent the user form logging in.
Note: Records can also be deleted in batches using the batch delete feature.
Deleting User Records from the Live App
App users have the ability to delete individual user records directly from the live app by including delete links in elements. These delete links will then appear in the element for users to access.
Tip: To learn more about applying delete links to your elements, see our article here.
User Settings
Each user has:
- Name: The name of the user logging in.
- Email: The email address used to login.
- Password: The password used to login. Passwords are immediately encrypted so cannot be added to an element to display.
- User Status: The status of the account determines if the user's login will allow them access or not.
- User Roles: Any user roles assigned to this user. User roles can be used to define permissions.
Users can have multiple roles - they'll have a record in each role's table.
Additional fields can be added to user role tables.
Tip: Click here to learn more on managing user records.
Using Users in Your App
Access Control
Create different permissions by:
- Adding login requirements to specific pages
- Choosing which roles can access each page
- Customizing what records each user can see
User roles are used to create different types of users.
For example, for a project management app, you may want Employee users who are responsible for completing project tasks and Supervisor users who are responsible for assigning tasks to Employees and approving new projects.
Each user can be assigned to multiple roles if necessary. A record will exist in each user role table that the user is assigned to.
These roles can be used to create different permissions to access your live app. When you add a login to a page, you can specify which roles can have permission to access that page:
This approach allows you to create separate pages for various roles. Each role will have access to different pages, each with distinct elements, fields, and workflows.
The page menu can be customized to display only the links to the pages that the logged-in user is authorized to access. As a result, each user will only be able to view the pages that they have been granted permission to see.
Setting Up Logins
To require login on a page:
- Go to Pages in Builder
- Click the menu icon next to the page
- Select "Require a login"
- Choose which roles can access it
You can also add a login from the lock icon at the top of the page navigation.
A special login page will be created containing a single login element. That login element controls the settings for the login and any user registration options.
Note: Adding login to a parent page automatically protects all child pages too. Every child page underneath that login page will now require a login to access.
Tip: Click here for more on managing logins and registrations.
Record Access
Let users see only their records by connecting user records to content. For example:
- Sales reps see only their customers
- Teachers see only their students
- Project managers see only their projects
Another key feature is building your app so that each user can log in and only access their own records.
For example, if you have a project management app showing Projects, you want each Project Manager to log in and see their own Projects, not the Projects of any other Project Managers.
When you add elements to a page that is protected by a login, you will have the opportunity to customize the element to suit your needs:
Once an employee logs in, they will have access to view only the Projects that are connected to their user record.
Tip: Click here for more on displaying records connected to the logged-in user.
Notes & Troubleshooting
Accounts User Role
The Accounts user role table stores all user records. When deleting a user record, it is important to remove the record from both the user role and the Accounts table.
Overwriting Changes Made in the Live App or Builder
It is important to note that changes made by other users in the Knack Builder or the Live App can potentially overwrite your own changes. In other words, there is currently no way to prevent users from accessing the builder or a record in the live app when it is being edited by another user in a different session.
As such, we strongly encourage the following:
- It is recommended that you have only one browser window or tab open while making changes to data in the Builder. If you or another shared builder on the app have an older version of the data open and save changes there, it can potentially overwrite the updates you have recently made.
- In the Live App, we encourage creating a workflow or process to limit the number of users that might need to edit the same record at any one time.
Updated 8 days ago