Skip to content

Commit

Permalink
Merge pull request #85 from kuzzleio/fix-refresh-param-getter
Browse files Browse the repository at this point in the history
What does this PR do?

Add a missing propagated refresh parameter to a user creation to fix this kind of inconsistent database (https://github.com/kuzzleio/kuzzle/runs/4934352096?check_suite_focus=true#step:6:439)

Boyscout

Use KuzzleRequest.getRefresh instead of KuzzleRequest.getString to retrieve the refresh parameter
  • Loading branch information
alexandrebouthinon authored Jan 25, 2022
2 parents 65ef8c5 + 659800a commit a66815a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
9 changes: 4 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class AuthenticationPlugin {
* @returns {Promise<object>}
*/
async create (request, credentials, kuid) {
const refresh = request.getString('refresh', 'wait_for');
const refresh = request.getRefresh('wait_for');

if (!credentials.password) {
throw new this.context.errors.BadRequestError('Password needed.');
Expand Down Expand Up @@ -420,7 +420,7 @@ class AuthenticationPlugin {
* @returns {Promise<object>}
*/
async update (request, credentials, kuid) {
const refresh = request.getString('refresh', 'wait_for');
const refresh = request.getRefresh('wait_for');

if (credentials.kuid) {
throw new this.context.errors.BadRequestError('The request must not contain a kuid attribute.');
Expand Down Expand Up @@ -480,8 +480,7 @@ class AuthenticationPlugin {
newDocument._id = credentials.username;
delete newDocument.username;

updated = await this.getUsersRepository().create(newDocument);
// wait for refresh only after the 2nd action
updated = await this.getUsersRepository().create(newDocument, { refresh });
await this.getUsersRepository().delete(oldDocumentId, { refresh });
}
else {
Expand All @@ -501,7 +500,7 @@ class AuthenticationPlugin {
* @returns {Promise<object>}
*/
async delete (request, kuid) {
const refresh = request.getString('refresh', 'wait_for');
const refresh = request.getRefresh('wait_for');

const user = await this.getCredentialsFromUserId(kuid);

Expand Down
11 changes: 1 addition & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-plugin-auth-passport-local",
"version": "6.3.5",
"version": "6.3.6",
"description": "Kuzzle plugin to log-in users",
"main": "./lib/index.js",
"repository": {
Expand Down

0 comments on commit a66815a

Please sign in to comment.