相关疑难解决方法(0)

AngularJs - 在等待新令牌时不跳过请求

我已经实现了身份验证系统,从角度1.0.8升级到1.2.x后,系统无法正常工作.当用户登录时获取令牌.令牌过期时,将调用新令牌的刷新功能.在服务器上成功创建新令牌,并将其存储到数据库.但是客户端没有获得这个新令牌,因此它再次请求一个新令牌,并一次又一次地请求它直到它注销.服务器端(MVC Web Api)工作正常,因此问题必须在客户端.问题必须在重试队列上.下面我粘贴了两个版本的应用程序(1.0.8和1.2.x)的相关代码和控制台跟踪.我现在正在努力奋斗这几天,我无法弄明白.

在下面的链接中,有5个相关的代码块:

  • interceptor.js(用于拦截请求,两个版本)
  • retryQueue.js(管理重试请求队列)
  • security.js(管理重试队列项的处理程序并从api获取新令牌)
  • httpHeaders.js(设置标题)
  • tokenHandler.js(处理cookie中的令牌)

代码:http://pastebin.com/Jy2mzLgj

应用程序的控制台跟踪角度为1.0.8:http://pastebin.com/aL0VkwdN

和角度1.2.x:http://pastebin.com/WFEuC6WB

interceptor.js(angular 1.2.x版)

angular.module('security.interceptor', ['security.retryQueue'])
.factory('securityInterceptor', ['$injector', 'securityRetryQueue', '$q',
     function ($injector, queue, $q) {
        return {
            response: function(originalResponse) {
                return originalResponse;
            },
            responseError: function (originalResponse) {
                var exception;
                if (originalResponse.headers){
                    exception = originalResponse.headers('x-eva-api-exception');
                }
                if (originalResponse.status === 401 && 
                   (exception === 'token_not_found' || 
                    exception === 'token_expired')){
                    queue.pushRetryFn(exception, function retryRequest() {
                        return $injector.get('$http')(originalResponse.config);
                    });
                }
                return $q.reject(originalResponse);
            }
        };
     }])
     .config(['$httpProvider', …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

5
推荐指数
1
解决办法
1041
查看次数

Angular JS从1.1.0升级到1.1.1后失败

当我升级时,ng-repeat需要非常长的时间来加载并尝试显示更多内容框而没有$ resource提供的内容.

我已将问题缩小到1.1.0和1.1.1之间的更新.我查看了更改日志,但没有任何东西突然出现在我身上,但它必须在那里.

Changelog => https://github.com/angular/angular.js/blob/master/CHANGELOG.md#111-pathological-kerning-2012-11-26

此应用程序的存储库=> https://github.com/brianpetro/resume

目前我的角度看起来像:

app = angular.module("Resume", ["ngResource"])

app.factory "Entry", ["$resource", ($resource) ->
  $resource("/entries")
]

@EntryCtrl = ["$scope", "Entry", ($scope, Entry) ->
  $scope.entries = Entry.query()
]
Run Code Online (Sandbox Code Playgroud)

使用ng-repeat在多个视图上发生这种情况:

<html ng-app="Resume">
  <div ng-controller="EntryCtrl">
    <ul>
      <li ng-repeat="entry in entries">
        {{entry.title}}
      </li>
    </ul>
  </div>
</html>
Run Code Online (Sandbox Code Playgroud)

这是AngularJS版本1.1.0: 这是AngularJS版本1.1.0 这是AngularJS版本1.1.1: 这是AngularJS 1.1.1版

javascript angularjs angular-resource angularjs-ng-repeat

4
推荐指数
1
解决办法
1387
查看次数