我有以下工作代码通过护照本地策略进行身份验证:
app.post('/api/login', passport.authenticate('local-login', {
successRedirect : '/api/login/success',
failureRedirect : '/api/login/error',
failureFlash : true
}));
app.get('/api/login/error', function(req, res) {
res.send(401, {error: req.flash('loginMessage')});
});
app.get('/api/login/success', function(req, res) {
res.send(200, {user: req.user});
});
Run Code Online (Sandbox Code Playgroud)
但是,理想情况下,我希望处理来自一条快速路由的错误和成功消息,而不是重定向到另外两条路由.
这可能吗?我尝试使用'自定义回调',但由于某种原因,似乎在序列化用户时出错.
我有一个带有 AVPreviewLayer 的全屏 avcapturesession。
当我切换相机时,预览层会正确显示视频,但保存后视频会颠倒。
我尝试过使用镜像和横向左/右属性来连接视频输出文件,但没有效果。
这是切换相机的方法:
- (void)swapFrontAndBackCameras {
// Assume the session is already running
NSArray * inputs = self . session.inputs;
for (AVCaptureDeviceInput * INPUT in inputs) {
AVCaptureDevice * Device = INPUT.device ;
if ( [ Device hasMediaType : AVMediaTypeVideo ] ) {
AVCaptureDevicePosition position = Device.position;
AVCaptureDevice * newCamera = nil;
AVCaptureDeviceInput * newInput = nil;
if(position == AVCaptureDevicePositionFront) {
newCamera = [ self cameraWithPosition : AVCaptureDevicePositionBack];
}
else
{
newCamera = [ self cameraWithPosition …Run Code Online (Sandbox Code Playgroud) 我想知道在使用API时在Flux中创建商店时的最佳实践或惯例是什么
假设我们有一个'项目'列表,API调用最终会填充_projects中名为ProjectStore的商店
然后,当用户选择项目时,您希望加载项目特定数据.您是否会将此添加到与_activeProject相同的ProjectStore中,或者为它创建一个单独的Store?
当您在该项目中加载Todo时也是如此.将它们放入TodoStore是有意义的,但是项目中Todos中的特定Todo呢?
我希望上面有道理:)
我为Model User定义了classMethod
// model user.js
classMethods: {
associate: function(models) {
User.belongsToMany(models.project, {through: 'user_project', foreignKey: 'user_id', otherKey: 'project_id'})
}
}
Run Code Online (Sandbox Code Playgroud)
从Express i中的路由然后查询该用户的项目并将其输出为JSON
user.getProjects({
attributes: ['id', 'title'],
})
.then(function(projects) {
res.json(projects)
})
Run Code Online (Sandbox Code Playgroud)
这工作正常,除了输出还包含user_project我想隐藏/省略/删除的属性
[
{
"id": 8,
"title": "Some project",
"user_project": {
"created_at": "2017-02-16T22:52:48.000Z",
"updated_at": "2017-02-16T22:52:48.000Z",
"project_id": 8,
"user_id": 5
}
},
//etc.
Run Code Online (Sandbox Code Playgroud)
我尝试了各种exclude和include语句,但输出总是包含它.
有没有办法在输出中没有这个显示?