示例#1
0
文件: User.php 项目: arbi/MyCode
 public function getAuthenticatedUserInfo()
 {
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $userDomain = new \DDD\Domain\User\User();
     if (!$auth->getIdentity()) {
         return false;
     }
     $userInfo = $auth->getIdentity();
     $userDomain->setId($userInfo->id);
     $userDomain->setFirstname($userInfo->firstname);
     $userDomain->setLastname($userInfo->lastname);
     $userDomain->setEmail($userInfo->email);
     $userDomain->setCity_id($userInfo->cityId);
     $userDomain->setCountry_id($userInfo->countryId);
     $userDomain->setAvatar($userInfo->avatar);
     $userInfoArray = ['id' => $userDomain->getId(), 'firstname' => $userDomain->getFirstname(), 'lastname' => $userDomain->getLastname(), 'email' => $userDomain->getEmail(), 'cityId' => $userDomain->getCity_id(), 'countryId' => $userDomain->getCountry_id()];
     $incidentPermission = $auth->hasRole(Roles::ROLE_MOBILE_INCIDENT_REPORT) ? true : false;
     $warehousePermission = $auth->hasRole(Roles::ROLE_MOBILE_ASSET_MANAGER) ? true : false;
     $userInfoArray['permissions']['warehouse'] = $warehousePermission;
     $userInfoArray['permissions']['incident'] = $incidentPermission;
     $userInfoArray['profileUrl'] = 'https:' . Helper::getUserAvatar($userDomain, 'big');
     return $userInfoArray;
 }
示例#2
0
 /**
  * @api {get} API_DOMAIN/ginosi-link/users User List
  * @apiVersion 1.0.0
  * @apiName GetUser
  * @apiGroup User
  *
  * @apiDescription This method returns the list of all users
  *
  * @apiHeader {String} Content-Type application/json
  * @apiHeader {String} Authorization Bearer ACCESS_TOKEN
  *
  * @apiSuccess {Int}    id         The unique identification of the user
  * @apiSuccess {String} firstname  The first name of the user
  * @apiSuccess {String} lastname   The last name of the user
  * @apiSuccess {String} avatar     The profile picture of the user
  *
  * @apiSuccessExample {json} Sample Response:
  *     HTTP/1.1 200 OK
  *     [
  *         {
  *             "id": "12",
  *             "firstname": "App",
  *             "lastname": "User",
  *             "avatar": "https://images.ginosi.com/profile/12/1439802421_0_150.png"
  *         }
  *     ]
  *
  * @param array $params
  * @return \Zend\Db\ResultSet\ResultSet
  */
 public function fetchAll($params = array())
 {
     try {
         $auth = $this->serviceLocator->get('library_backoffice_auth');
         $requestHandler = $this->serviceLocator->get('Service\\RequestHandler');
         $userManagerDao = new \DDD\Dao\User\UserManager($this->serviceLocator, 'ArrayObject');
         $countryId = $auth->getIdentity()->countryId;
         $usersInfo = $userManagerDao->getUserByCountry($countryId, ['id', 'firstname', 'lastname', 'avatar']);
         $usersInfoArray = [];
         foreach ($usersInfo as $userInfo) {
             $userInfo['avatar'] = 'https:' . Helper::getUserAvatar($userInfo, 'big');
             $usersInfoArray[] = $userInfo;
         }
         return $usersInfoArray;
     } catch (\Exception $e) {
         return $requestHandler->handleException($e);
     }
 }