colymba / silverstripe-restfulapi

SilverStripe RESTful API with a default JSON serializer.
BSD 3-Clause "New" or "Revised" License
64 stars 33 forks source link

Access to token on dataobjects #86

Closed rodwin closed 6 years ago

rodwin commented 6 years ago

Thank you for this module.

Is there a way to access the token inside the onAfterSerialize or onBeforeDeserialize or anywhere in the dataobject?

I need to get some user details to be included on the response and I think using Member::currentUserID() is not ideal since its using session.

Thanks

colymba commented 6 years ago

Hey! if the token auth extension is on the Member class, the authenticator calls this Session::set("loggedInAs", $tokenOwner->ID); when a Member is authenticated, so with Session::get("loggedInAs") you get the Member ID and can do a DB call to get the DO. If Member::currentUserID() works, I would use it.

rodwin commented 6 years ago

Thanks. Closing this now