• このエントリーをはてなブックマークに追加

関連記事

(日本語) Blowfishを使用してハッシュ化する

Sorry, this entry is only available in 日本語.

(日本語) コントローラ内でバリデーション処理を呼び出す

Sorry, this entry is only available in 日本語.

DebugKit Installation

Installing DebugKit after finished Blog tutorial. You will be able to download from here for CakePH

(日本語) バリデーションエラーメッセージの取得

Sorry, this entry is only available in 日本語.

(日本語) RSSフィードの取得

Sorry, this entry is only available in 日本語.

(日本語) バリデーション前後に処理を追加できる「beforeValidate」「afterValidate」

Sorry, this entry is only available in 日本語.

(日本語) 複数ファイルアップロードフォーム

Sorry, this entry is only available in 日本語.

(日本語) checkボックスを実装

Sorry, this entry is only available in 日本語.

(日本語) 多言語サイト向けに翻訳ファイルを使って翻訳を行う

Sorry, this entry is only available in 日本語.

(日本語) Formヘルパーのinputタグのdiv/labelなどの設定

Sorry, this entry is only available in 日本語.

Comment

  1. confirmPasswordですが、常にfalseになるため、以下の処理に書き換えましたが何か処理を忘れているのでしょうか

       public function confirmPassword( $field, $password, $password_confirm) {
            if ($this->data[$this->name][$password] == $this->data[$this->name][$password_confirm]) {
                // パスワードハッシュ化
                $this->request->data['User']['password'] = Security::hash( $password, 'sha512', true);
                return true;
            }
        }
    
    • コメントありがとうございます。
      いただいたコードが正しいようです。勝手ながら、修正に上記を使用させていただきます。
      ご指摘いただき、ありがとうございました。

  2. とても参考になります!ありがとうございます!

    1点質問がございます。
    signupアクションの5行目にて、

    $this->User->save( $this->data)
    

    がございますが、私のコントローラーでは都合上、項目ごとに登録する必要がございまして、

    'password' => $this->request->data['User']['password']
    

    としているのですが、上記だとパスワードがnullになります。
    かと言って、

    'password' => $this->request->data['User']['plain']
    

    とするとハッシュ化されていないパスが登録されてしまいます。

    上記の場合どのように指定すれば良いかお教え願えませんでしょうか。


    本登録(activate)アクションの3行目は、

    $this->User->id = user_id;
    ↓
    $this->User->id = $user_id;
    

    ですよね??

    • コメントありがとうございます。

      $this->User->save( $this->data)

      の前にハッシュ化する処理を追加してみて下さい。

      $this->request->data['User']['password'] = Security::hash( $this->request->data['User']['plain'], 「ハッシュタイプ」, true);

      (この投稿では、モデル内のconfirmPasswordバリデーションで行っています。)

      user_idの件、確かに!ありがとうございました。

Leave a Reply to [CakePHP] ユーザ登録とログイン認証を実装する (1) | 端くれプログラマの備忘録 Cancel reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    PAGE TOP ↑