mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
doc/privacy: initial version for privacy feature (#843)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Privacy Admin Example
|
||||
# Privacy Admin Only Example
|
||||
|
||||
An example for an application that allows any user to read any data,
|
||||
but accepts mutations only from viewers with admin role.
|
||||
|
||||
@@ -27,12 +27,12 @@ func (User) Fields() []ent.Field {
|
||||
// Policy defines the privacy policy of the User.
|
||||
func (User) Policy() ent.Policy {
|
||||
return privacy.Policy{
|
||||
Mutation: []privacy.MutationRule{
|
||||
Mutation: privacy.MutationPolicy{
|
||||
rule.DenyIfNoViewer(),
|
||||
rule.AllowIfAdmin(),
|
||||
privacy.AlwaysDenyRule(),
|
||||
},
|
||||
Query: []privacy.QueryRule{
|
||||
Query: privacy.QueryPolicy{
|
||||
privacy.AlwaysAllowRule(),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user