-
Notifications
You must be signed in to change notification settings - Fork 122
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
Allows createUser to create a user without passing an id. #149
Conversation
Forces updateUser to actually use the update action
Current coverage is
|
+1 |
@@ -329,6 +330,9 @@ module.exports = function SecurityController (kuzzle) { | |||
if (newRequestObject.data._id !== undefined) { | |||
pojoUser._id = newRequestObject.data._id; | |||
} | |||
else { | |||
pojoUser._id = uuid.v4(); |
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.
Why don't we put 'anonymous'
instead, so that the user repository returns an anonymous user?
That would be more efficient than reading the cache, and then the database, to search for a purposely unknown user.
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.
This was actually the situation this PR tries to solve.
The createUser action should create a real user when no id is provided and not update the anonymous user.
Note that the user is not fetched here. We only hydrate a new user with the pojoUser and persist it forcing a write:create call.
If the user id already exists in elasticsearch, the write:create action will trigger an error.
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.
Oh, ok. I clearly misunderstood the purpose of this PR, sorry :-)
+1 |
1 similar comment
👍 |
Allows createUser to create a user without passing an id.
Forces updateUser to actually use the update action