Skip to main content

Add Auth, Roles

Now, we have three rules that we need to connect to the users.

  1. 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)

  2. Create two new _auth records, which both have the cryptoUser role.

    To create an auth, we'll specify:

    • id : We'll use cryptoMan and cryptoWoman
    • doc : A docstring to explain this auth
    • roles : This is a reference to the relevant _roles. To reference the role we are creating in this same transaction, you'll need to use tempids.

    (See all _auth predicates).

  3. Connect _auth to _users we created several steps back.

    The usernames from the users we created are cryptoMan and cryptoWoman. We'll need to reference those _users 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.