From 2152c988bfcca2743a72bef7efb77e0b10a55297 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 19 Nov 2019 14:06:44 +0000 Subject: [PATCH] Use new hash getter to authenticate --- src/commands/securesign_activatekey.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/securesign_activatekey.ts b/src/commands/securesign_activatekey.ts index 24c78e1..7c7d74a 100644 --- a/src/commands/securesign_activatekey.ts +++ b/src/commands/securesign_activatekey.ts @@ -19,17 +19,18 @@ export default class SecureSign_ActivateKey extends Command { if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`); if (!account.hash) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not initialized***`); const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Activating key...***`); + const hash = this.client.util.getAcctHash(account.username); try { await axios({ method: 'POST', url: 'https://api.securesign.org/account/keys/activation', - headers: { Authorization: account.hash, 'Content-Type': 'application/json' }, + headers: { Authorization: hash, 'Content-Type': 'application/json' }, data: JSON.stringify({ key: args[0] }), }); } catch (error) { const { code } = error.response.data; if (code === 1001) { - await this.client.db.Account.updateOne({ hash: account.hash }, { $set: { hash: null } }); + await this.client.db.Account.updateOne({ userID: account.userID }, { $set: { hash: false } }); this.client.getDMChannel(account.userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account')).catch(); return msg.edit(`${this.client.stores.emojis.error} ***Authentication failed***`); }