server/app/ws/routes/meta.authenticate.js

20 lines
586 B
JavaScript
Raw Normal View History

2020-11-27 01:57:37 +00:00
module.exports = exports = async (message, di) => {
const Token = di.models.get('Token')
const { token_value } = message.data()
const token = await Token.findOne({ active: true, token_value })
if ( token ) {
message.socket.session.is_auth = true
message.socket.session.token_value = token_value
message.socket.session.user_uuid = token.user_uuid
return message.send_response(
message.fresh().data({ is_auth: true })
)
}
return message.send_response(
message.fresh().data({ is_auth: false })
)
}