小编wis*_*nIV的帖子

我是否实现了序列化和反序列化NodesJS + Passport + RedisStore?

我实现Serialize和Deserialize吗?

RedisStore设置为Express的会话存储.这是否意味着我不实现Serialize和Deserialize?它会自动发生吗?

当我没有实现这些方法时,我得到以下Express错误 - 500错误:无法将用户序列化为会话.当我实现它们时,我不确定在Deserialize中放入什么.

下面的代码似乎有效,但会话不会持续存在.我每次访问该网站时都需要登录.

在NodeJS + Passport + RedisStore的任何地方都有一个很好的例子吗?

var sessionStore = new RedisStore({
                                        host: rtg.hostname,
                                        port: rtg.port,
                                        db: redisAuth[0],
                                        pass: redisAuth[1]
                                      });

passport.use(new ForceDotComStrategy({
    clientID: clientId,
    clientSecret: clientSecret,
    callbackURL: myurl
},
function(token, tokenSecret, profile, done) {
    console.log(profile);
    return done(null, profile);
  }
));

appSecure.configure('production', function(){
appSecure.use(allowCrossDomain);
appSecure.use(express.cookieParser(expressSecret));
appSecure.use(express.bodyParser());
appSecure.use(express.methodOverride());
appSecure.set('port', port); 
appSecure.use(express.session({ secret: expressSecret, store: sessionStore, key:'expressSid', cookie: { maxAge : 604800, domain:'.domain.com'}})); 
appSecure.use(passport.initialize());
appSecure.use(passport.session());
appSecure.use(appSecure.router);
appSecure.use(express.static(__dirname + '/public'));
appSecure.use(express.errorHandler());
});

passport.serializeUser(function( user, done ) {
    done( null, …
Run Code Online (Sandbox Code Playgroud)

redis node.js express passport.js

18
推荐指数
3
解决办法
2万
查看次数

基于动态数据的ng-repeat中用于不同AngularJS指令的模式

我正在从一组数据动态构建仪表板.仪表是D3.

我在AngularJS指令中定义了一系列不同的D3测量仪.在我的页面上,我有一个ng-repeat迭代度量数组.

我的问题是什么是基于ng-repeat数组中的数据属性动态选择正确指令的最佳方法?

有没有办法创建一个工厂模式,其中使用的指令是基于数组的输入值?或者是否有办法通过动态地在指令中包含其他指令来仅使用指令来实现结果?

HTML

<div ng-controller="DashboardCtrl">
<div id="oppChart">
    <div>
        <gh-visualization ng-repeat="item in metrics" val="item[0]"></gh-visualization>
    </div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)

度量数组(将是动态的):

$scope.list = [
        { 'title': 'XYX','data-type':'', 'query':'SELECT ...' },
        { 'title': 'Revenue', 'data-type':'', 'query':'SELECT ...'  }
      ];
Run Code Online (Sandbox Code Playgroud)

D3指令基于此 - http://briantford.com/blog/angular-d3.html

angularjs angularjs-directive

6
推荐指数
2
解决办法
1462
查看次数

AngularJS中跨域REST调用的正确架构模式是什么?

我创建了一个直接从客户端访问Salesforce REST API的AngularJS服务.但是,由于相同的原产地限制,我无法使其正常工作.即使访问非经过身份验证的REST服务并尝试$ http,$ http.json和Ajax.我也尝试了很多Json,Jsonp等的组合.

鉴于我有这么多问题,我认为我的一般方法是不正确的.也许我需要为此设置代理服务器?我的后端是Firebase,所以我目前没有自己的服务器.

我不相信Salesforce API支持COR,我无法改变它.

这是我尝试使用$ http和Ajax的一个例子.

return $http.jsonp('https://na1.salesforce.com/services/data/',{
headers: {
    'Content-type': 'application/json', 'Accept': 'application/json'
}}). 
                success(function (data, status, headers, config) {

                    callback(data);
                    console.debug(data.json);
                }).
                error(function (data, status, headers, config) {
                    console.debug("getVersions: failed to retrieve data: "+eval(data));
                });


$.ajax({
              url: 'https://na15.salesforce.com/services/data',
          type: "GET",
              dataType: "jsonp",
              beforeSend: function(xhrObj){
                                  xhrObj.setRequestHeader("Content-Type","application/json");
                                  xhrObj.setRequestHeader("Accept","application/json");
                                  xhrObj.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                              },
              success: function (data) {
                  console.debug(data);
                  callback(data);
              },
              error: function(data) {

              }
          });
Run Code Online (Sandbox Code Playgroud)

salesforce angularjs angularfire

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

初始化AngularJS服务工厂样式

我有一个通过REST检索数据的服务.我想将结果数据存储在服务级别变量中,以便在多个控制器中使用.当我将所有REST逻辑直接放入控制器时,一切正常,但是当我尝试将数据的检索/存储移动到服务中时,控制器在数据恢复时不会被更新.我已经尝试了很多不同的方法来维护服务和控制器之间的绑定.

控制器:

myApp.controller('SiteConfigCtrl', ['$scope', '$rootScope', '$route',  'SiteConfigService',
function ($scope, $rootScope, $route, SiteConfigService) {

    $scope.init = function() {
        console.log("SiteConfigCtrl init");
        $scope.site = SiteConfigService.getConfig();
    }

}

]);
Run Code Online (Sandbox Code Playgroud)

服务:

 myApp.factory('SiteConfigService', ['$http', '$rootScope', '$timeout', 'RESTService',
 function ($http, $rootScope, $timeout, RESTService) {

    var siteConfig = {} ;

    RESTService.get("https://domain/incentiveconfig", function(data) {
        siteConfig = data;
    });

    return {

        getConfig:function () {
            console.debug("SiteConfigService getConfig:");
            console.debug(siteConfig);

            return siteConfig;
        }

     };
 }
]);
Run Code Online (Sandbox Code Playgroud)

视图:

<div class="span4" ng-controller="SiteConfigCtrl">
            <header>
                <h2>
                    {{site.title}}
                </h2>
            </header>
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-service angularjs-controller

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