Skip to content

Commit

Permalink
Fix invalid role check with running script
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Mar 1, 2022
1 parent a465cef commit d76d175
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vigiechiro/xin/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ class Validator(GenericValidator):
def _run_attribute_postonly(self, context):
"""Field can be altered by non-admin during POST only"""
post_only = context.schema['postonly']
if g.request_user['role'] == 'Administrateur':
if "request_user" in g and g.request_user['role'] == 'Administrateur':
return
if post_only and request.method != 'POST':
context.add_error(ERROR_READONLY_FIELD)
Expand All @@ -528,7 +528,7 @@ def _run_attribute_writerights(self, context):
write_roles = context.schema['writerights']
if isinstance(write_roles, str):
write_roles = [write_roles]
if g.request_user['role'] not in write_roles:
if "request_user" in g and g.request_user['role'] not in write_roles:
context.add_error(ERROR_READONLY_FIELD)

def _run_type_objectid(self, context):
Expand Down

0 comments on commit d76d175

Please sign in to comment.