ajax - PHPBB 3.1.10 Dependency Injection of User Object only delivers Anonymous User in a live environment -
the goal login status of user in phpbb 3.1.10 in extension module using ajax calls.
i have succeded on xampp on local machine. (meaning problem described not exist in environment) trying roll out online site installing extension on live phpbb installation.
the problem opposed local environment @user object delivered dependency injection mechanism "anonymous", no matter if logged in or not.
"anonymous" username of phpbb user not logged in.
- both envrionments use phpbb 3.1.10.
- the folder structure deviates in name of phpbb3 root folder name.
- both have functioning url rewrite now, after had manually set live environments rewritebase in .htaccess.
- board settings seem identical domain.
as php server settings - have no direct influence on php config on live environmenht .htaccess , have little knowladge possible in regard.
here service defintion, routing information , authorization class used read @user object.
ext/foo/bar/services.yml
services: foo.bar.helper.auth: class: foo\bar\helper\auth arguments: - '@user' - '%core.root_path%' - '%core.php_ext%'
ext/foo/bar/config/routing.yml
foo_bar_getuserstatus: path: /getuserstatus defaults: { _controller: foo.bar.helper.auth:getuserstatus }
ext/foo/bar/helper/auth.php
<?php namespace foo\bar\helper; class auth{ /* @var \phpbb\user */ protected $user; /** @var string */ protected $root_path; /** @var string */ protected $php_ext; /** * constructor * * @param \phpbb\user $user * @param string $root_path * @param string $php_ext php ext * @access public */ public function __construct( \phpbb\user $user, $root_path, $php_ext) { $this->user = $user; $this->root_path = $root_path; $this->php_ext = $php_ext; include_once($this->root_path . 'includes/functions_user.' . $this->php_ext); } // authorization public function __getuserstatus(){ $userstatus = array( 'isloggedin' => false ); if ($this->user->data['is_registered'] && ! $user->data['is_bot']){ $userstatus['isloggedin'] = true; $admins_group_id = '5'; if(group_memberships($admins_group_id, $this->user->data['user_id'], true)){ $userstatus['isadmin'] = true; } } return $userstatus; } public function getuserstatus(){ return new \symfony\component\httpfoundation\jsonresponse(array( 'success' => $this->__getuserstatus() )); } }
update 11.01.17
i have managed extension run on fresh installation of phpbb 3.2 (which released recently) , php 7.0. (running in same server environment live one)
i still have no idea yet why user object not set properly. have not checked out yet if migrating data phpbb 3.1.10 fresh installation of phpbb 3.2 feasible me.
it take time me figure things out i'm not working full time on it.
Comments
Post a Comment