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.
This commit is contained in:
parent
0de9f61e8d
commit
1256e73d90
@ -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
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user