私はcakephp 2.xiに取り組んでおり、データベース名userにテーブルがあり、id、email、password、mobileNoの4つのフィールドがあります
login.ctpに 2 つのフィールドがあります
<?php
echo $this->form->create();
echo $this->form->input('email');
echo $this->form->input('password');
echo $this->form->end('submit');
?>
私が欲しいのは、Facebookが行ったのと同じように、彼のmobileNoからもユーザーにログインしたいです(彼が電子メールアドレスではなく携帯電話番号を入力した場合)..彼はhi電子メールアドレスまたはmobilenoでログインできます.別の入力を作成したくない.フィールド..これを行う方法がわからない ここに私のコードがあります
AppController
class AppController extends Controller {
public $components = array(
'Session',
'Auth'=>array(
'loginRedirect'=>array('controller'=>'users', 'action'=>'admin'),
'logoutRedirect'=>array('controller'=>'users', 'action'=>'admin'),
'authError'=>"You can't access that page",
'authorize'=>array('Controller'),
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'email')
)))
);
)
);
public function isAuthorized($user) {
}
public function beforeFilter() {
$this->Auth->allow('index');
}
}
ユーザーコントローラー
public function login()
{
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Your email/password combination was incorrect');
}
}
}