This article aims to provide you with comprehensive information on implementing Users in your Knack app and effectively managing them.
What are Users?
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, users will now be required to log in before they can access the app.
If a login is added, the app will appear as follows:
To gain access to the app, an email and password are now necessary. Individuals who possess an email and password to log in and utilize the app are referred to as 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. This will enable users for your app.
Note: You can also activate users by selecting "Enable Users" under the User Roles section of your Tables list.
While activating users, 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.
Adding User Roles
When you enable user and login features, a unique "Accounts" table is automatically included in your app. 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.
However, you can also add additional user roles. These are different types of user "types" and will allow you to customize their permissions in the Live App.
To add new user roles, select the green "+" button to the right of the "User Roles" text. This will walk you through creating a new user role:
Adding User Records
Once you have enabled users, you have the ability to add individual users to your app. This can be done by adding records to your user roles.
To add a new user, 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.
Editing User Roles
To edit user roles, you have the option to click on the settings icon next to the user role name or select the "Settings" tab at the top of the Builder when viewing the user role.
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 view, 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, views, and connections that use this user role.
Deleting User Records
You have the flexibility to delete individual user records either from the Builder or the Live App.
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.
Deleting User Records from the Live app
App users have the ability to delete individual user records directly from the live app by including deleted links in views. These deleted links will then appear in the view for users to access.
You have the option to select multiple user records using checkboxes and enable additional management features:
As an example, you have the ability to approve multiple pending registered users simultaneously by updating their status and sending them an email notification informing them of the approval:
Tip: Click here to learn more on managing user records.
Using Users in Your App
Roles and Permissions
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 views, 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.
Adding User Logins
You have the option to require a login for any page in your live app.
To add a login, go to the Pages section of the Builder, then select the page you want to protect with a login. Click on the icon next to the page's name, and then select "Require a login".
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 view. That login view controls the settings for the login and any user registration options.
Note: Every child page underneath that login page will now require a login to access.
Tip: Click here for more on managing logins and registrations.
Limiting Records to the Logged-in User
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 views to a page that is protected by a login, you will have the opportunity to customize the view 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.
How To Guides