Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 27, 20168 yr 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 ); }
March 27, 20168 yr \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.
Archived
This topic is now archived and is closed to further replies.