In [ch-users] we put Documents directly the database to represent an initial User.
Operations can’t be invoked without a User, yet Operations, but Operations are required to create Users. We had a chicken-and-egg situation that we resolved by directly inserting the first user by hand.
However, now that we have built the capability to create Operations and Permissions, we can build the Operations to create new Users, User Identities and Subjects. That’s the subject of this chapter.
An Operation to create a User should take a new Document describing the User,
validate that the :juxt.site.alpha/type
attribute is set to
https://meta.juxt.site/pass/user
and other required checks. For example, a
User might be required to have a name and other required attributes.
Creating an operation to put a user demonstrates the creation of an Operation that fulfils these criteria.
link:../../test/juxt/book.clj[role=include]
Here we grant the REPL user access to perform this Operation.
link:../../test/juxt/book.clj[role=include]
-
Check the format of the id.
-
Check the type.
-
Default the type, if not given in the argument.
-
Allow the user details to be retrieved via the GET method, with the
https://site.test/operations/get-user
Operation. -
Ensure only roles with a Permission are able to perform this Operation.
Important
|
Copy the code in Creating an operation to put a user, paste it into a REPL and evaluate. |
In the same way, we may also need the ability to create a User Identity. For this Operation it is important that the Document given in the document refers to the User it is identifying.
See Creating an Operation to put a User Identity for a demonstration of creating and permitting an Operation that meets these requirements.
link:../../test/juxt/book.clj[role=include]
Here we grant the REPL user access to perform this Operation.
link:../../test/juxt/book.clj[role=include]
Important
|
Copy the code in [ex-create-operation-put-identity], paste it into a REPL and evaluate. |
link:../../test/juxt/book.clj[role=include]
Here we grant the REPL user access to perform this Operation.
link:../../test/juxt/book.clj[role=include]
Important
|
Copy the code in Creating an operation to put a subject, paste it into a REPL and evaluate. |