Welcome to the Cookbook

loading...

5.2.5.8 password

password (string $password)

文字列を渡すと、ハッシュ化されたものを取得できます。 この機能は、ログイン済みのユーザに対して、アプリケーションの重要な領域にアクセスさせる前にもう一度パスワードを入力してもらう時などに重要となります。

if ($this->data['User']['password'] ==
    $this->Auth->password($this->data['User']['password2'])) {

    // Passwords match, continue processing
    ...
} else {
    $this->flash('Typed passwords did not match', 'users/register');
}
  1. if ($this->data['User']['password'] ==
  2. $this->Auth->password($this->data['User']['password2'])) {
  3. // Passwords match, continue processing
  4. ...
  5. } else {
  6. $this->flash('Typed passwords did not match', 'users/register');
  7. }

認証コンポーネントは、送信されたデータの中に「username」フィールドがある場合、自動的に「password」フィールドをハッシュ化します。