cakePHPのバージョン2.5を使ってAuthコンポーネントで認証をつけようとしています。
さくらインターネットを利用しているのですが、
usersテーブルのパスワードが暗号化されません。
考えられる理由としてどのような原因が考えられるのでしょうか?
usersコントローラーのソースは下記です。
初期データのusersのデータを登録しているので、
http://aaa.jp/users/add を利用し、情報を登録しようとしています。
申し訳ございませんが、よろしくお願い致します。
php
1<?php 2App::uses('AppController', 'Controller'); 3/** 4 * Users Controller 5 * 6 * @property User $User 7 * @property PaginatorComponent $Paginator 8 */ 9class UsersController extends AppController { 10 11 12 public $helpers = array('Html', 'Form'); 13/** 14 * Components 15 * 16 * @var array 17 */ 18 public $components = array( 19 'Paginator', 20 // 以下、Authコンポーネント設定 21 'Auth' => array( 22 // ログインページのパス 23 'loginAction' => array('controller' => 'users', 'action' => 'login'), 24 25 // ログイン後のページを指定 26 'loginRedirect' => array('controller' => 'accounts', 'action' => 'index'), 27 28 // ログアウト後の移動先 29 'logoutRedirect' => array('controller' => 'users', 'action' => 'login'), 30 31 // 未ログイン時のメッセージ 32 'authError' => 'あなたのお名前とパスワードを入力して下さい。', 33 ) 34 ); 35 36 public function beforeFilter(){ 37 //親クラスのbeforeFilterの読み込み 38// parent::beforeFilter(); 39 //認証不要のページの指定 40// $this->Auth->allow('login','add'); 41 $this->Auth->allow('login','logout','add'); 42 } 43 44 public function login() 45 { 46 // titleタグ 47 $this->set('title_for_layout', 'ログイン'); 48 49 if ($this->request->is('post')){ 50 if ( $this->Auth->login() ) { 51 $this->redirect($this->Auth->redirect('/accounts/index')); 52 } else { 53 $this->Session->setFlash(__('ユーザ名、メールアドレス、パスワードが不正です。')); 54 } 55 } 56 } 57 58 public function logout(){ 59 $this->Auth->logout(); 60 $this->Session->destroy(); //セッションを完全削除 61 $this->Session->setFlash(__('ログアウトしました')); 62 $this->redirect(array('action' => 'login')); 63 } 64 65/** 66 * index method 67 * 68 * @return void 69 */ 70 public function index() { 71 $this->User->recursive = 0; 72 $this->set('users', $this->Paginator->paginate()); 73 } 74 75/** 76 * view method 77 * 78 * @throws NotFoundException 79 * @param string $id 80 * @return void 81 */ 82 public function view($id = null) { 83 if (!$this->User->exists($id)) { 84 throw new NotFoundException(__('Invalid user')); 85 } 86 $options = array('conditions' => array('User.' . $this->User->primaryKey => $id)); 87 $this->set('user', $this->User->find('first', $options)); 88 } 89 90/** 91 * add method 92 * 93 * @return void 94 */ 95 public function add() { 96 if ($this->request->is('post')) { 97 $this->User->create(); 98 if ($this->User->save($this->request->data)) { 99 $this->Session->setFlash(__('The user has been saved.')); 100 return $this->redirect(array('action' => 'index')); 101 } else { 102 $this->Session->setFlash(__('The user could not be saved. Please, try again.')); 103 } 104 } 105 106 } 107 108/** 109 * edit method 110 * 111 * @throws NotFoundException 112 * @param string $id 113 * @return void 114 */ 115 public function edit($id = null) { 116 if (!$this->User->exists($id)) { 117 throw new NotFoundException(__('Invalid user')); 118 } 119 if ($this->request->is(array('post', 'put'))) { 120 if ($this->User->save($this->request->data)) { 121 $this->Session->setFlash(__('The user has been saved.')); 122 return $this->redirect(array('action' => 'index')); 123 } else { 124 $this->Session->setFlash(__('The user could not be saved. Please, try again.')); 125 } 126 } else { 127 $options = array('conditions' => array('User.' . $this->User->primaryKey => $id)); 128 $this->request->data = $this->User->find('first', $options); 129 } 130 131 } 132 133/** 134 * delete method 135 * 136 * @throws NotFoundException 137 * @param string $id 138 * @return void 139 */ 140 public function delete($id = null) { 141 $this->User->id = $id; 142 if (!$this->User->exists()) { 143 throw new NotFoundException(__('Invalid user')); 144 } 145 $this->request->allowMethod('post', 'delete'); 146 if ($this->User->delete()) { 147 $this->Session->setFlash(__('The user has been deleted.')); 148 } else { 149 $this->Session->setFlash(__('The user could not be deleted. Please, try again.')); 150 } 151 return $this->redirect(array('action' => 'index')); 152 } 153} 154
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。