我正在使用他们的 fb 用户 ID 登录用户。因此,我在登录用户时不需要用户名或密码。这工作正常。但是,当我尝试访问时,$this->Auth->user
什么都没有保存。请看下面的代码。
$this->authUser = $this->User->findById($user_profile['id']);
if($this->authUser){
if($this->Auth->login($this->authUser)){
$this->redirect('/Users/dash');
}
有任何想法吗?
如果我调试$this->Auth
而不是进行重定向,我会得到以下信息:
object(AuthComponent) {
components => array(
(int) 0 => 'Session',
(int) 1 => 'RequestHandler'
)
authenticate => array(
(int) 0 => 'Form'
)
authorize => array(
(int) 0 => 'Controller'
)
ajaxLogin => null
flash => array(
'element' => 'default',
'key' => 'auth',
'params' => array()
)
loginAction => array(
'controller' => 'users',
'action' => 'login',
'plugin' => null
)
loginRedirect => null
logoutRedirect => array(
'controller' => 'users',
'action' => 'login',
'plugin' => null
)
authError => 'You can't access that page'
allowedActions => array(
(int) 0 => 'index',
(int) 1 => 'view'
)
request => object(CakeRequest) {
params => array(
'plugin' => null,
'controller' => 'Users',
'action' => 'index',
'named' => array(),
'pass' => array()
)
data => array(
'signed_request' => 'Xyx9uGB4OZT_S59w-sMmJe5ofuzCwib2F1dGhfdG9rZW4iOiJBQUFEcDlCdlpDMzRjQkFJSlBaQ3VwVGtoTlJRRGdIWkJEU0IxeWlTZDFhRTNLcXg1TzJma2Ewek1yOUlrTkVUZTBWbGNpaUxhMFpDUWFQd0ZOWVF3MnZyU1B4NXFrV2VqMjlOMzY4NXJ2d1pEWkQiLCJwYWdlIjp7ImlkIjoiMjQ3ODg2NjY1MzMxOTgwIiwibGlrZWQiOnRydW8BPoTx2YAtQtdin0.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEzNDYyNjMyMDAsImlzc3VlZF9hdCI6MTM0NjI1NzU3NUsImFkbWluIjp0cnVlfSwidXNlciI6eyJjb3VudHJ5IjoiZ2IiLCJsb2NhbGUiOiJlbl9HQiIsImFnZSI6eyJtaW4iOjIxfX0sInVzZXJfaWQiOiI2NjEyNjMzODgifQ'
)
query => array()
url => 'Users/index'
base => ''
webroot => '/'
here => '/Users/index'
}
response => object(CakeResponse) {
}
settings => array(
'authError' => 'You can't access that page',
'authorize' => array(
(int) 0 => 'Controller'
)
)
Session => object(SessionComponent) {
settings => array()
components => array()
}
}
谢谢!