我可以使用Auth->login($this->data)
登录用户。登录后调试Auth->user()
所有我看到的是用户名和密码。 Id应该自动填充还是我需要手动设置它?通过几个教程,似乎ID应该已经存在。
什么是调试:
\app\Controller\UsersController.php (line 90)
array(
'User' => array(
'password' => '*****',
'username' => 'LittleRy'
)
)
作为ndm评论,我将呼叫更改为Auth->login()
,因此它应该抓取请求信息。通过此更改,login()
始终返回false。以下是登录表单。我相信一切都正确传递。
<div class="users form">
<?php echo $this->Session->Flash('auth');
?>
<?php echo $this->Form->create('User'); ?>
<fieldset>
<legend>
<?php echo __('Please enter your username and password'); ?>
</legend>
<?php echo $this->Form->input('username');
echo $this->Form->input('password');
?>
</fieldset>
<?php echo $this->Form->end(__('Login')); ?>
</div>
答案 0 :(得分:0)
试试这个$ this-&gt; Auth-&gt; user('id');获得用户ID。