public function insert() { $this->salt = uniqid(mt_rand(), TRUE); $this->passHash = Identity::passHash($this->password, $this->salt); $this->password = NULL; $this->created = new \DateTime('now'); parent::insert(); }
/** * Call * * Pulls out a anonymous sent from an http header * * Perform actions specific to this middleware and optionally * call the next downstream middleware. */ public function call() { /** * Finds overridable Application Model (default -> Named Application -> annotated 'option ApplicationModel') * There can only be one. * * @var $applicationModelClass \MABI\Model */ $applicationModelClass = '\\MABI\\DefaultApplicationModel'; $mabi = $this->getApp(); $modelClasses = $mabi->getModelClasses(); foreach ($modelClasses as $modelClass) { if (ReflectionHelper::stripClassName($modelClass) == 'Application') { $applicationModelClass = $modelClass; } $rClass = new \ReflectionClass($modelClass); $modelOptions = ReflectionHelper::getDocDirective($rClass->getDocComment(), 'model'); if (in_array('ApplicationModel', $modelOptions)) { $applicationModelClass = $modelClass; break; } } // Find the shared secret property (named sharedSecret or annotated 'field SharedSecret') $rClass = new \ReflectionClass($applicationModelClass); $modelProps = $rClass->getProperties(\ReflectionProperty::IS_PUBLIC); $sharedSecretProp = 'sharedSecret'; foreach ($modelProps as $modelProp) { $rProp = new \ReflectionProperty($applicationModelClass, $modelProp->name); $propOptions = ReflectionHelper::getDocDirective($rProp->getDocComment(), 'field'); if (in_array('SharedSecret', $propOptions)) { $sharedSecretProp = $modelProp->name; break; } } $this->apiApplication = $applicationModelClass::init($mabi); if (!$this->apiApplication->findByField($sharedSecretProp, $mabi->getRequest()->headers('SHARED-SECRET'))) { $this->apiApplication = FALSE; } $mabi->getRequest()->apiApplication = $this->apiApplication; if (!empty($this->next)) { $this->next->call(); } }
public function insert() { $this->created = new \DateTime('now'); $this->lastAccessed = new \DateTime('now'); if (!empty($this->user)) { $this->userId = $this->user->userId; } $this->email = NULL; $this->password = NULL; parent::insert(); // TODO: Change the autogenerated stub }