Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
IPBWI.com Matthias Reuter Posted March 27, 2016 Posted March 27, 2016 I'm working on a REST-API for "reports" object. If utilizing method "report" (/ipb/system/Content/Content.php), the "report_by" field in line 810 will be set to currently logged in user: 'report_by' => (int) \IPS\Member::loggedIn()->member_id, So my question is: How can I set the logged in user for a REST API call? Otherwise all actions performed and all permission checks will be based upon guest role what's limiting possible features drastically. So here is my current state: public function POSTindex() { /* this doesn't load a member as logged in globally. $member_id = \IPS\Request::i()->member_id; $member = \IPS\Member::load($member_id); */ if($this->ipbwi_valid_classes[\IPS\Request::i()->content_type]){ $content_type_class = $this->ipbwi_valid_classes[\IPS\Request::i()->content_type]; }else{ $content_type_class = \IPS\Request::i()->content_type; } $content = $content_type_class::load(\IPS\Request::i()->content_id); try { $r = $content->report(\IPS\Request::i()->report_message); // cannot set a reporting member ID here, method uses currently logged in member only } catch ( \OutOfRangeException $e ) { throw new \IPS\Api\Exception( 'INVALID_ID', '2C292/7', 404 ); } return new \IPS\Api\Response( 201, (array)$r ); }
Colonel_mortis Posted March 27, 2016 Posted March 27, 2016 \IPS\Member::$loggedInMember = \IPS\Member::load($member_id); Disclaimer: I haven't actually tested this, so don't blame me if it makes your server explode. It ought to work though.
IPBWI.com Matthias Reuter Posted March 27, 2016 Author Posted March 27, 2016 you are aweseome! Just works. How can I thank you?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.