scaphold-io / scaphold-issues

Post issues that you find on Scaphold here. Post anything about the platform, docs, boilerplates, etc... Happy Scapholding!
3 stars 0 forks source link

Feature: User information on pre hooks #20

Open martinheidegger opened 7 years ago

martinheidegger commented 7 years ago

I would like to implement automatic creator assignment in some of my scaphold types. I thought to be best doing that with logic hooks (preferably pre hooks). Unfortunately at the moment scaphold does only send the payload data and no information on users. It would be sufficient to get the user id & roles of the person requesting.

mikeparisstuff commented 7 years ago

A simple fix could be to send the id of the logged in user and then the hook can issue queries using the id to ask for any additional information? The round trip to get the full user info isn't ideal but the only other way I could see it working is if you supplied a query in the logic function almost like how you provide a selection set in post-op functions.

mikeparisstuff commented 7 years ago

Thoughts on this? I'm trying to keep the logic workflows as light weight as possible but I definitely see the value of having the logged in user information.

martinheidegger commented 7 years ago

the userid would suffice. i was wondering if the roles might be useful too.

On Feb 20, 2017 18:00, "Michael" notifications@github.com wrote:

Thoughts on this? I'm trying to keep the logic workflows as light weight as possible but I definitely see the value of having the logged in user information.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scaphold-io/scaphold-issues/issues/20#issuecomment-281022477, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3yyrF2IQBzAH8t1GmqKZ8-PVWr_QMqks5reVY-gaJpZM4MFv-X .

mikeparisstuff commented 7 years ago

My only concern with passing roles by default is that at scale certain apps might have users enrolled in 100+ of them. Ideally you would be able to ask for certain fields. E.G. as if you had issued a query through viewer.user.

In the short term I will get it so it passes the user id while we discuss this.

martinheidegger commented 7 years ago

ok cool!

On Feb 20, 2017 18:33, "Michael" notifications@github.com wrote:

My only concern with passing roles by default is that at scale certain apps might have users enrolled in 100+ of them. Ideally you would be able to ask for certain fields. E.G. as if you had issued a query through viewer.user.

In the short term I will get it so it passes the user id while we discuss this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scaphold-io/scaphold-issues/issues/20#issuecomment-281029492, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3yynRrdLnd-SVYnOmURBw-BhghDSMzks5reV3ZgaJpZM4MFv-X .

mikeparisstuff commented 7 years ago

I just pushed this update. You can now grab the logged in user under the user key in the request payload. If you are logged in as an admin user in the portal the object will look like { email: '<>', isAdmin: true } so you can audit admin activity as well. If you are logged in as a user of your app it will look like { id: '<>' }. I will keep this issue open because this will be expanded to allow you to provide a selection set so you can ask for further user details.

martinheidegger commented 7 years ago

Thinking about implementing it: It would be nice if the user and systemUser would be different properties.