This article will cover the management of user records in your Knack app.
What are User Records?
When you activate users on your app, a unique Accounts table is automatically created. This table serves as a storage space for each user who can log in to your app using their email and password.
These users are recorded as account records, allowing for efficient management of user accounts and logins.
User records are similar to records in regular tables, however contain special user fields that help manage user accounts and logins. These user fields are indicated by a user icon to the right of the field name:
- Name: The name of the account the user logs in as.
- Email: The email address used to login.
- Password: The password used to login. Passwords are immediately encrypted so cannot be added to a view 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.
These special user fields can be edited but not deleted.
Each user's User Role record counts as an additional record toward your record limit, in addition to their record in Accounts. For example, a user in the Employees user role counts as two records: one for the record in Accounts and one for the record in Employees.
If the user is also part of the HR user role, they count as three records: one for Accounts, one for Employees, and one for HR.
Activating User Records
Before you can use user records with your app, you must first enable Users.
You can learn more about Users and how to activate them here.
Managing User Records
When it comes to adding, editing, and deleting user records, the process works in a similar way to managing any other records in your Knack database.
You can learn more on managing all app records here.
Adding User Records
User records are the same as regular records in Knack, so they can be inserted in the same ways: adding them individually from the Builder, importing from a spreadsheet, or from a form in your Live App.
In addition, users have the option to add user records using specialized registration forms. Users have the option to configure logins in a way that allows them to click on a "sign up" link when they visit a page without an existing account.
This link will redirect them to a registration form where they can create a new account.
For more information, take a look at our article on Logins and Registrations.
Editing User Records
To edit user records, simply click on the pen icon next to the record in the Records section of your Builder or edit the record directly inline.
It is also possible to build your app to allow for editing in the Live App. You can learn more on this here.
Deleting User Records
To remove user records, simply select the User Record and click on the Delete button in the Records section of the Builder.
User Role Settings
If there are multiple user tables, the field for user roles will display the roles assigned to each user. Users have the ability to be assigned to more than one role if necessary.
When user roles are assigned, a record representing that user will be created in both the main Accounts table and each User Role table to which the user is assigned.
If you make changes to a user's Name, Email, Password, User Status, or User Roles, all of those records will be automatically updated, no matter where those fields were edited.
Editing the User Roles will add/remove records from the respective user roles that are assigned to the user. For example, if you edit a user's roles to add an "Employee" role, a new record will be inserted into the Employee table for that user.
Updating User Status
Different statuses can be assigned to users, which will impact how they can access the app.
User accounts can be assigned one of three different statuses in the Account record:
- Active: Only users with their status set to "active" will be allowed to login.
- Inactive: Users will be unable to login and will receive a notification indicating that they do not have access.
- Pending Approval: Users will be unable to log in and will receive a notification informing them that their registration is awaiting approval from an administrator.
By utilizing checkboxes (as shown in the image above), you have the ability to simultaneously update the status of multiple users. This functionality also provides you with the option to send an approval email, notifying them that they now have access to the app.
To send these emails, make sure to select the checkbox labeled "Send approval email to selected users." For more details on customizing this email, refer to the section below on Approval and Account Templates.
Editing the User Status inline on the record from "inactive" or "pending approval" will not automatically trigger this approval email to send.
Emailing Account Info
You have the ability to send emails to users, providing them with important information about their account, including links to access the app. This feature is particularly useful if you manually add users or import them from a spreadsheet.
Use the checkboxes to select the user records you want to email and click the “Email Info” button:
See the section below on Approval and Account Templates for further information about customizing this email.
You have the option to reset a user's password and send them an email containing instructions on how to reset it.
To reset the passwords, simply select the user records you wish to email and click on the "Reset Passwords" button.
Account and Approval Templates
To customize the email template that your users receive after their approval, simply click on the arrow down button icon next to the User Role table and select the Settings option.
Next, you have the option to choose the "Approval Template" or "Account Info Template" to customize the content of the email that will be sent to your users.
In addition to your email content, you have the option to incorporate user variables that will utilize the values from the user record:
- : Extract and display the first name from the user name field.
- : Display the user email field value.
Passwords cannot be included in any emails. This is because passwords are immediately encrypted for security reasons and are never stored in a readable form.
Ensure that you update the link in the email template to correspond with the specific user login page.
Notes & Troubleshooting
- If a user is unable to access a page, it is important to verify that they have a record within the user role that grants them access to the page.
- It is not possible to add multiple records with the same email address.