From 1256e73d90c43803fdab97944d7a61ffbc1648f2 Mon Sep 17 00:00:00 2001 From: William Boman Date: Thu, 30 Jun 2016 03:17:42 +0200 Subject: [PATCH] src/client: pass the updated token as argument to callback This also fixes an issue where the token would not be stored in the user file. --- src/client.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/client.js b/src/client.js index fa7fbbff..fbee8975 100644 --- a/src/client.js +++ b/src/client.js @@ -69,8 +69,8 @@ function Client(manager, name, config) { if (config) { if (!config.token) { - client.updateToken(function() { - client.manager.updateUser(client.name, {token: config.token}); + client.updateToken(function(token) { + client.manager.updateUser(client.name, {token: token}); }); } @@ -245,17 +245,16 @@ Client.prototype.updateToken = function(callback) { var client = this; crypto.randomBytes(48, function(err, buf) { - client.config.token = buf.toString("hex"); - callback(); + callback(client.config.token = buf.toString("hex")); }); }; Client.prototype.setPassword = function(hash, callback) { var client = this; - client.updateToken(function() { + client.updateToken(function(token) { client.manager.updateUser(client.name, { - token: client.config.token, + token: token, password: hash });