2017-03-01 56 views
1

我已经设置了羽化认证,它需要羽毛认证版本1 feathersjs。它使用app.authenticate工作正常,但它使用套接字时失败。启用调试后,我确认服务器获取凭证并成功生成令牌。然而,客户无法获得回应。服务器正在发出“已创建身份验证”,客户只有在使用socket.on('authentication created')时才会使用app.authenticate()。我知道我可以使用普通套接字并完成工作,但文档建议使用app.authenticate,然后使用app.service('someService')羽毛认证版本1 app.authenticate不与插座配合使用

下面的代码段可以正常工作,但不适用于套接字。

app.authenticate({ 
    type: 'local', 
    endpoint: '/authentication', 
    strategy: 'ldap', 
    'username': 'user', 
    'password': 'password' 
}).then(function(result){ 
    console.log('Authenticated!', app.get('token')); 
}).catch(function(error){ 
    console.error('Error authenticating!', error); 
}); 

这是我如何设置插座:

var socket = io(apiDomain, { 
    transport: ['websockets'] 
}); 

// Set up Feathers client side 
var app = feathers() 
.configure(feathers.socketio(socket)) 
.configure(feathers.hooks()) 
.configure(feathers.authentication({ storage: window.localStorage })); 

回答