當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crypto::aes256Decode方法代碼示例

本文整理匯總了PHP中Crypto::aes256Decode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypto::aes256Decode方法的具體用法?PHP Crypto::aes256Decode怎麽用?PHP Crypto::aes256Decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crypto的用法示例。


在下文中一共展示了Crypto::aes256Decode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateNewEmail

 /**
  * Validate the new email for a user
  */
 public function validateNewEmail()
 {
     $tokenData = json_decode(Crypto::aes256Decode(base64_decode($this->token)), true);
     try {
         if (!$tokenData) {
             // Token format is not valid
             throw new \Exception();
         }
         $user = User::getById($tokenData['userId']);
         if ($user->email !== $tokenData['currentEmail']) {
             // Token does not have the correct email corresponding to the user email
             throw new \Exception();
         }
         if ($tokenData['createTime'] < time() - 86400) {
             // Token has expired
             throw new \Exception();
         }
         // Everything OK, change the user's email address
         $user->set('email', $tokenData['newEmail']);
         $user->save();
         // Disconnect the user
         session_destroy();
         $status = 'success';
         $messageKey = 'main.reset-email-success';
     } catch (\Exception $e) {
         $messageKey = 'main.reset-email-invalid-token';
         $status = 'error';
     }
     $this->addJavaScriptInline('
         require(["app"], function(){
             app.notify("' . $status . '", "' . addcslashes(Lang::get($messageKey), '"') . '");
         });');
     return MainController::getInstance()->main();
 }
開發者ID:elvyrra,項目名稱:hawk,代碼行數:37,代碼來源:UserProfileController.php

示例2: resetPassword

 /**
  * Display and treat the form to reset the user's password
  */
 public function resetPassword()
 {
     $form = new Form(array('id' => 'reset-password-form', 'fieldsets' => array('form' => array(new TextInput(array('name' => 'code', 'required' => true, 'label' => Lang::get($this->_plugin . '.reset-pwd-form-code-label'))), new PasswordInput(array('name' => 'password', 'required' => true, 'label' => Lang::get($this->_plugin . '.reset-pwd-form-password-label'), 'encrypt' => array('\\Hawk\\Crypto', 'saltHash'))), new PasswordInput(array('name' => 'confirmation', 'required' => true, 'compare' => 'password', 'label' => Lang::get($this->_plugin . '.reset-pwd-form-confirmation-label')))), 'submits' => array(new SubmitInput(array('name' => 'valid', 'label' => Lang::get($this->_plugin . '.valid-button'))), new ButtonInput(array('name' => 'cancel', 'label' => Lang::get($this->_plugin . '.cancel-button'), 'href' => App::router()->getUri('login'), 'target' => 'dialog')))), 'onsuccess' => 'app.dialog(app.getUri("login"));'));
     if (!$form->submitted()) {
         return Dialogbox::make(array('title' => Lang::get($this->_plugin . '.reset-pwd-form-title'), 'icon' => 'lock-alt', 'page' => $form));
     } else {
         if ($form->check()) {
             // Check the verficiation code
             if ($form->getData('code') !== Crypto::aes256Decode(App::session()->getData('forgottenPassword.code'))) {
                 $form->error('code', Lang::get($this->_plugin . '.reset-pwd-form-bad-verification-code'));
                 return $form->response(Form::STATUS_CHECK_ERROR);
             }
             try {
                 $user = User::getByEmail(App::session()->getData('forgottenPassword.email'));
                 if ($user) {
                     $user->set('password', $form->inputs['password']->dbvalue());
                     $user->save();
                 } else {
                     return $form->response(Form::STATUS_ERROR, App::session()->getData('forgottenPassword.email'));
                 }
                 return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.reset-pwd-form-success'));
             } catch (\Exception $e) {
                 return $form->response(Form::STATUS_ERROR, Lang::get($this->_plugin . '.reset-pwd-form-error'));
             }
         }
     }
 }
開發者ID:elvyrra,項目名稱:hawk,代碼行數:30,代碼來源:LoginController.php


注:本文中的Crypto::aes256Decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。