-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validates permission before calling beforeSave trigger #5546
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two questions and a request for a comment.
@@ -220,6 +220,34 @@ RestWrite.prototype.runBeforeSaveTrigger = function() { | |||
} | |||
|
|||
return Promise.resolve() | |||
.then(() => { | |||
let databasePromise = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment here, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just done
@@ -831,13 +849,19 @@ class DatabaseController { | |||
.then(schema => { | |||
transformAuthData(className, object, schema); | |||
flattenUpdateOperatorsForCreate(object); | |||
if (validateOnly) { | |||
return object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is getting returned here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original object that would go to the database but in the case of validateOnly, it is just returned after the validations.
@@ -588,6 +602,9 @@ class DatabaseController { | |||
'Object not found.' | |||
); | |||
} | |||
if (validateOnly) { | |||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what will result
be in a validateOnly
case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both cases (create and update), it is returning the original object.
…ty#5546) * Test to reproduce the problem * Validating update before calling beforeSave trigger * Fixing lint * Commenting code * Improving the code
Solves issue #5513