-1

ここでは、CAKEPHP 2.3 の完全なログインおよび認証アプリケーションのチュートリアルで、認証機能を構築するためのいくつかのヒントを得ました。

現在、ctp ファイルの代わりに html を使用するPHPTALを使用しています。
html ファイルを使用して Cake の認証に協力している人はいますか?

ありがとう。

アップデート:

login.html [表示]

<form method="POST" tal:attributes="action string:/users/login">
   <input type="text" name="username" size="15" maxlength="30" placeholder="your email" /><br />
   <input type="password" name="password" size="15" maxlength="15" placeholder="password" /><br />
    input type="submit" value="log in" />
</form>

UsersController.php [コントローラ]

public $components = array('RequestHandler',
        'Auth' => array(
                'authenticate' => array(
                        'Form' => array('userModel' => 'User',
                                'fields' => array('username' => 'email',
                                        'password' => 'password'))),
                'loginRedirect' => array('controller' => 'pages', 'action' => 'display',
                        'landing'),
                'logoutRedirect' => array('controller' => 'new_boards', 'action' => 'login'),
                'loginAction' => array('controller' => 'pages', 'action' => 'display',
                        'landing'),
                'authError' => 'Input youer email and password correctly, please',));`

public function beforeFilter() {
    $this->Auth->allow('login', 'logout', 'viewUser', 'showHome');

    if ($this->Session->check('User.100000001.id')) {
        $this->current_user_id = $this->Session->read('User.100000001.id');
    } else {
        $this->current_user_id = 100000001;
    }
}

public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {// failed here
            return $this->redirect($this->Auth->redirect());
        } else {
            $this->Session->setFlash(__('wrong email or password'), 'default', array(), 'auth');
        }
    }
}

しかし、データベースにユーザー テーブルを作成していません。これは問題ですか?

4

2 に答える 2

0

私はちょうど今それを2か月以上見て解決しました。

先ほど返信した Google グループ ディスカッションのこちらをご覧ください。

同様の問題を抱えている人に幸運を!

于 2015-02-14T15:11:20.493 に答える