<@U04UQ68083H> Wwhat is the standard way to check ...
# ory-copilot
m
@chilly-king-10285 Wwhat is the standard way to check if a user can do an action ? What I would like is to check if
user
can
edit
(permission) the file
myfile
from the
File
namespace. I do not want to check if
user
is
editors
(relationship) of the file
myFile
.
c
A message from kapa.ai
To check if a user can perform an action, such as
edit
, you should use Ory Keto's [check-API](https://www.ory.sh/docs/keto/concepts/api-overview#check-relation-tuple) to determine whether the user (subject) has a specific relation on an object. In your case, you want to check if the user can
edit
the file
myfile
from the
File
namespace. Based on the information provided in the extracts, you should check for a specific permission like
edit
instead of a relationship like
editors
. The permission model will define which relationships are checked in the process. For example, if you have these permissions defined in your permission model: -
view
a document if the user is a
viewer
,
editor
, or
owner
of the document; or if the user can
view
the parent folder -
edit
a document if the user is a
editor
, or
owner
of the document; or if the user can
edit
the parent folder You can use the check-API to check if the user has the
edit
permission on the file
myfile
. The permission check will look up the relationships (like
editor
or
owner
) defined in the permission model. Unfortunately, the extracts do not provide a specific code example for this scenario. However, you can refer to the [Ory Keto documentation](https://www.ory.sh/docs/keto) for more information on how to use the check-API and set up your permission model.