私は CakePHP 2.0 を使用しており、サイトのユーザー管理フォームで忙しいです。問題は、データベースからユーザー情報行を呼び出すと、パスワードが暗号化された形式で読み取られ、フォーム要素に長い文字列が入力されることです (暗号化されたパスワードを想定しています)。
保存すると、8 文字に制限されているため、検証規則が壊れます (パスワードの暗号化されたバージョンを保存したくないので、これは良いことです)。
また、フィールドを空白のままにすることはできません。これは、人々が検証ルールを保存して再び失敗する可能性があるためです (パスワードが入力されていません)。
これを克服する最善の方法は何ですか?行に入力されたパスワードを8文字のダミーパスワードに置き換えて検証チェックを行うことを考えましたが、a)誰かが同じパスワードを使用する可能性があり、b)元のパスワードを取得するには別の検索を行う必要があるため、それは機能しませんこれも意味がありません。
何か助けはありますか?
// Controller EDIT:
public function edit($id = null) {
$this->User->id = $id;
if(!$this->User->exists()) {
$this->Session->setFlash(__('The user does not exist'));
$this->redirect(array('action' => 'index'));
} else {
if($this->request->is('post') || $this->request->is('put')) {
if($this->User->save($this->request->data)) {
$this->Session->setFlash('The user has been updated','default',array('class'=>'success'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
$this->request->data = $this->User->read(null, $id);
$userTypes = $this->User->UserType->find("list");
$userStatuses = $this->User->UserStatus->find("list");
$this->set(compact("userTypes","userStatuses"));
}
}
// HTML Form:
<?php echo $this->Form->create('User');?>
<fieldset>
<legend><?php echo __('Modify User '); ?></legend>
<h3><?php echo $this->Html->link("Return to user index",array("controller" => "users","action" => "index")); ?></h3>
<?php
echo $this->Form->input('username');
echo $this->Form->input('password',array("id" => "profilePassword","empty" => true, "autocomplete" => "off"));
echo $this->Form->input('company');
echo $this->Form->input('first_name');
echo $this->Form->input('last_name');
echo $this->Form->input('telephone');
echo $this->Form->input('fax');
echo $this->Form->input('user_status_id');
echo $this->Form->input('user_type_id');
?>
</fieldset>
<?php echo $this->Form->end(__('Update'));?>