Esempio n. 1
0
 /**
  * @param      $actionId  int El id de la acción
  * @param      $authToken string El token de seguridad
  * @param null $userPass  string La clave del usuario
  * @throws SPException
  */
 public function __construct($actionId, $authToken, $userPass = null)
 {
     if (!Auth::checkAuthToken($actionId, $authToken)) {
         throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
     }
     $this->_userId = ApiTokens::getUserIdForToken($authToken);
     $this->_actionId = $actionId;
     $this->_auth = true;
     if (!is_null($userPass)) {
         $userLogin = UserUtil::getUserLoginById($this->_userId);
         $User = new User();
         $User->setUserId($this->_userId);
         $User->setUserLogin($userLogin);
         $User->setUserPass($userPass);
         if (Auth::authUserMySQL($userLogin, $userPass) && !UserUtil::checkUserIsDisabled($userLogin) && UserPass::checkUserMPass($User) && UserPass::checkUserUpdateMPass($userLogin) && !$User->isUserChangePass()) {
             $this->_mPass = $User->getUserMPass(true);
         } else {
             throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
         }
     }
     Session::setUserId($this->_userId);
 }
Esempio n. 2
0
 /**
  * Obtener los datos para la ficha de tokens de API
  */
 public function getToken()
 {
     $this->view->addTemplate('tokens');
     $token = \SP\ApiTokens::getTokens($this->view->itemId, true);
     $this->view->assign('users', \SP\DB::getValuesForSelect('usrData', 'user_id', 'user_name'));
     $this->view->assign('actions', \SP\ApiTokens::getTokenActions());
     $this->view->assign('token', $token);
     $this->view->assign('gotData', is_object($token));
     if ($this->view->isView === true) {
         $msg = sprintf('%s ;;Usuario: %s', _('Token de autorización visualizado'), $token->user_login);
         Log::writeNewLogAndEmail(_('Autorizaciones'), $msg);
     }
 }