Add Auth, Roles
Now, we have three rules that we need to connect to the users.
In order to do this, we need to create a new role that has all three rules we created in the past two lessons.
To create a role, we need to specify:
- id : We'll use
cryptoUser
- doc : A docstring to explain this role
- rules : We can use two tuples to reference the three rules we just created. So you don't have to refer back to the last lesson, the
_rule/id
for the rules we just created are, cantEditWalletUser, editAnyCryptoBalance, and editOwnWalletName.
(See all _role predicates)
- id : We'll use
Create two new
_auth
records, which both have thecryptoUser
role.To create an auth, we'll specify:
- id : We'll use
cryptoMan
andcryptoWoman
- doc : A docstring to explain this auth
- roles : This is a reference to the relevant
_role
s. To reference the role we are creating in this same transaction, you'll need to use tempids.
(See all _auth predicates).
- id : We'll use
Connect
_auth
to_user
s we created several steps back.The usernames from the users we created are
cryptoMan
andcryptoWoman
. We'll need to reference those_user
s as the value of the_id
key.We'll also need to specify `_auth`:
- auth : This is a reference to the relevant `_auth`s. To reference the auths we are creating in this same transaction, you'll need to use [tempids](/docs/overview/transact/basics#temporary-ids).
Create Auth and Role!
Quiz Question:
Using the instructions above, create a role, two auth records, and connect those auth records to the two users we created earlier.