在req中提供用户设置

时间:2016-10-01 09:14:48

标签: sails.js passport.js

我知道护照会在req.user中暴露当前用户(我认为使用'护照'政策)。我想对特定用户的设置做类似的事情,这些设置存储在一个单独的集合中(以便它们在req.settings中可用)。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

serializeUser方法负责https://github.com/jaredhanson/passport#sessions

$("#launchPad").height($(window).height() - 20);
var dropSpace = $(window).width() - $("#launchPad").width();
$("#dropZone").width(dropSpace - 10);
$("#dropZone").height($("#launchPad").height());

$(".card").draggable({
    appendTo: "body",
    cursor: "move",
    helper: 'clone',
    revert: "invalid",
});

$("#launchPad").droppable({
    tolerance: "intersect",
    accept: ".card",
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {
        $("#launchPad").append($(ui.draggable));
    }
});

$(".stackDrop1").droppable({
    tolerance: "intersect",
    accept: ".card",
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {        
        $(this).append($(ui.draggable));

    }
});

$(".stackDrop2").droppable({
    tolerance: "intersect",
    accept: ".card",
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {        
        $(this).append($(ui.draggable));
    }
});

因此,您不仅可以序列化passport.serializeUser(function(user, done) { done(null, user.id); }); ,还可以序列化设置:

user.id

您可能需要阅读Safe to store complete user info in session with Sails.js?

相关问题