Skip to content

Conversation

@derrickmehaffy
Copy link
Member

Signed-off-by: Derrick Mehaffy derrickmehaffy@gmail.com

What does it do?

Adds a PUT /users/me route by default to the users-permissions plugin

Why is it needed?

Requested by users

Related issue(s)/PR(s)

#2818

Signed-off-by: Derrick Mehaffy <derrickmehaffy@gmail.com>
@codecov
Copy link

codecov bot commented Nov 19, 2020

Codecov Report

Merging #8698 (11456a4) into master (c38e1c4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #8698   +/-   ##
=======================================
  Coverage   33.65%   33.65%           
=======================================
  Files        1248     1248           
  Lines       13765    13765           
  Branches     1365     1365           
=======================================
  Hits         4632     4632           
  Misses       8243     8243           
  Partials      890      890           
Flag Coverage Δ
front 25.33% <ø> (ø)
unit 54.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b6c1e2...11456a4. Read the comment docs.

Signed-off-by: Derrick Mehaffy <derrickmehaffy@gmail.com>
Signed-off-by: Derrick Mehaffy <derrickmehaffy@gmail.com>
@strapi-cla
Copy link

strapi-cla commented Nov 30, 2020

CLA assistant check
All committers have signed the CLA.

return ctx.badRequest('ValidationError', err);
}

const updatedUser = await strapi.plugins['users-permissions'].services.user.edit(ctx.state.user.id, input);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incase some one needs this
Change - services.user.edit({ id: ctx.state.user.id }, input);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't recommend using this yet, it's only a prototype with no validation or security yet.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure
This Pointed me in the right direction , i have added my own validations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good day! But maybe we can made it this way?

async updateme (ctx) {
    // Get user id from context
    const { id } = ctx.state.user;
    // Set id to params. strapi.plugins["users-permissions"].controllers.user.update use it.
    ctx.params.id = id;
    // Use default Strapi Update User function
    return strapi.plugins["users-permissions"].controllers.user.update(ctx);
 }

@derrickmehaffy
Copy link
Member Author

This pull request has been mentioned on Strapi Community Forum. There might be relevant details there:

https://forum.strapi.io/t/applying-isowner-policy-to-user-permissions-plugin/1782/2

@mo9a7i
Copy link

mo9a7i commented Dec 30, 2020

What's the plan for this one ?

@derrickmehaffy
Copy link
Member Author

What's the plan for this one ?

Currently nothing, I'm marking as closed as I don't have time to finish it. Someone else can pick this up if they like.

@derrickmehaffy derrickmehaffy deleted the users/updateMe branch March 29, 2021 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants