Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用角度装置获取上一个会话_Angularjs_Devise - Fatal编程技术网

Angularjs 使用角度装置获取上一个会话

Angularjs 使用角度装置获取上一个会话,angularjs,devise,Angularjs,Devise,我正在尝试使用Auth.currentUser()从angular Device获取有效响应 根据以下文件: 我正在执行: Auth.currentUser().then(function (user) { // User was logged in, or Devise returned // previously authenticated session. console.log('Auth', user); console.log('isAuth',

我正在尝试使用Auth.currentUser()从angular Device获取有效响应

根据以下文件:

我正在执行:

  Auth.currentUser().then(function (user) {
    // User was logged in, or Devise returned
    // previously authenticated session.
    console.log('Auth', user);
    console.log('isAuth', Auth.isAuthenticated()); // => false
  }, function (error) {
    // unauthenticated error
    console.log('Autherror', error)
    console.log('isAuth', Auth.isAuthenticated()); // => false
  });
这将导致对login.json进行401次未经授权的调用

在我的配置中,我设置了:

$httpProvider.defaults.withCredentials = true;
我注意到在http请求中,负载有一个空的用户对象:

{"user":{}}
上下文:我的应用程序中有成功允许新用户注册的路径。当用户通过注册进入时,Auth.currentUser()返回一个有效对象,但不进行api调用:

Auth Object {id: 98, email: "casey@tom.com", first_name: "tom", last_name: "casey", created_at: "2014-12-04T19:55:40.981Z"…}
create.js?body=1:10 isAuth true