20 lines
586 B
JavaScript
20 lines
586 B
JavaScript
|
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 })
|
||
|
)
|
||
|
}
|