AngularJS资源处理服务器端laravel会话失败,无法重定向到登录页面

时间:2019-01-31 11:50:34

标签: angularjs angularjs-directive angular-ui-router

我在laravel端登录会话时遇到问题。当会话在服务器端登录时,整个功能运行良好。当会话注销时,它将以json格式返回登录页面html。我想将其重定向到登录页面。我的知识不足以解决这种情况。在这种情况下需要帮助。谢谢

function resourscesController($scope,$q, AccountModel) {
  var self = this;
  self.name = 'Plunker';

  self.getRecords = function() {
    var deferred = $q.defer();
    AccountModel.find({
      id: null,
    }).then(
      function(response) {
        deferred.resolve({
          user: response,
        });
      },
      function(error) {
        deferred.resolve({});
      }
    );
  };
}

resourscesController.$inject = ['$scope','$q', 'AccountModel'];
var app = angular.module('testResources',['ngResource']);
app.controller('resourscesController', resourscesController);

AccountModel服务

function AccountModel(AccountResource) {
  var model = this;
  model.dashboardList = [];

  model.find = function(id) {
    return AccountResource.find(id).$promise;
  };
}
AccountModel.$inject = ['AccountResource'];
app.service('AccountModel', AccountModel);

AccountResource工厂

function AccountResource($resource) {
   return $resource(website_url+'getuser',
     {
       requestType: '@requestType',
    },
    {
      find: {
        method: 'GET',
        params: {
          id: '@id',
        },
      },
    }
  );
}
AccountResource.$inject = ['$resource'];
app.factory('AccountResource', AccountResource);

用户登录时响应

  

{id:1157,名称:“ spgone公司名称”,电子邮件:“ spgone01@test.com”,   状态:1,…}确认代码:“ e285a54ed0c04c97000ab8baf890669e”   确认:1 created_at:“ 2019-01-17 12:04:36” delete_at:空电子邮件:   “ spgone01@test.com” listen_us:“ Facebook” ID:1157 is_first_time:“ 0”   job_notifications:“ 1”名称:“ spgone企业名称” other_option:“”   profile_pic:2278 profilepic:{id:2278,名称:   “ 1547726765_thumb_small_1527657128_Man-PNG-Pic.png”,路径:   “ / assets / user / large /”,…} profilevideo:空等级:0角色:[{id:5,   名称:“ ServiceProvider”,全部:0,排序:5,created_at:“ 2016-02-07”   18:29:36“,…}] show_buiness_wizard:1 social_medias_list:[{id:1,   media_name:“ Facebook”,media_key:“ facebook”,media_logo:   “ images / facebook-logo.png”,…},…]状态:1 sub_newletter:1   Updated_at:“ 2019-01-31 10:01:36” userSocialMediaAccounts:{facebook:   ““, 推特: ””,…}   user_business:{id:357,user_id:1157,…} user_info:{id:1047,   user_id:1157,contact_number:“ 0322156465456”,地址:null,郊区:   “ PARLIAMENT HOUSE”,…} user_payment_info:[] user_social_accounts:   [{id:318,user_id:1157,键:“ facebook”,值:   “”},…] user_subscription:[{id:159,user_id:   1157,plan_id:2,plan_status:1,起始日期:“ 2019-01-17   12:04:37“,...}]视频:空

用户注销时响应

  

0:“” 1:“↵” 2:“ <” 3:“!” 4:“ D” 5:“ O” 6:“ C” 7:“ T” 8:“ Y” 9:“ P”   10:“ E” 11:“” 12:“ h” 13:“ t” 14:“ m” 15:“ l” 16:“>” 17:“” 18:   “↵” 19:“ <” 20:“ h” 21:“ t” 22:“ m” 23:“ l” 24:“” 25:“ l” 26:“ a”   27:“ n” 28:“ g” 29:“ =” 30:“”“ 31:” e“ 32:” n“ 33:”“” 34:“>” 35:“   “ 36:”↵“ 37:” <“ 38:” h“ 39:” e“ 40:” a“ 41:” d“ 42:”>“ 43:”“ 44:   “↵” 45:“” 46:“” 47:“” 48:“” 49:“ <” 50:“ m” 51:“ e” 52:“ t”   53:“ a” 54:“” 55:“ c” 56:“ h” 57:“ a” 58:“ r” 59:“ s” 60:“ e” 61:   “ t” 62:“ =” 63:“”“ 64:” u“ 65:” t“ 66:” f“ 67:”-“ 68:” 8“ 69:”“”   70:“>” 71:“” 72:“↵” 73:“” 74:“” 75:“”

0 个答案:

没有答案