예제 #1
0
파일: Save.php 프로젝트: nblair/magescotch
 /**
  * Process saving new encryption key
  *
  * @return void
  */
 public function executeInternal()
 {
     try {
         $key = null;
         if (0 == $this->getRequest()->getPost('generate_random')) {
             $key = $this->getRequest()->getPost('crypt_key');
             if (empty($key)) {
                 throw new \Exception(__('Please enter an encryption key.'));
             }
             $this->encryptor->validateKey($key);
         }
         $newKey = $this->change->changeEncryptionKey($key);
         $this->messageManager->addSuccessMessage(__('The encryption key has been changed.'));
         if (!$key) {
             $this->messageManager->addNoticeMessage(__('This is your new encryption key: <span style="font-family:monospace;">%1</span>. ' . 'Be sure to write it down and take good care of it!', $newKey));
         }
         $this->cache->clean();
     } catch (\Exception $e) {
         $this->messageManager->addErrorMessage($e->getMessage());
         $this->_session->setFormData(['crypt_key' => $key]);
     }
     $this->_redirect('adminhtml/*/');
 }
예제 #2
0
 /**
  * Return a validated encryption key, generating a random one, if no value was initially provided
  *
  * @param string|null $key
  * @return string
  */
 public function getValidEncryptionKey($key = null)
 {
     if (!$key) {
         $key = md5($this->mathRandom->getRandomString(10));
     }
     $this->_encryptor->validateKey($key);
     return $key;
 }