Yet another bugfix for alias & PIN authrecall

This commit is contained in:
mhelander 2018-01-29 23:58:52 +02:00
parent 491356382f
commit 8e44147f45

8
sea.js
View File

@ -499,7 +499,7 @@
let err let err
// Yes, then attempt to log into each one until we find ours! // Yes, then attempt to log into each one until we find ours!
// (if two users have the same username AND the same password... that would be bad) // (if two users have the same username AND the same password... that would be bad)
const [ { key, at, proof } = {} ] = await Promise const [ { key, at, proof, pin: newPin } = {} ] = await Promise
.all(aliases.filter(({ at: { put } = {} }) => !!put) .all(aliases.filter(({ at: { put } = {} }) => !!put)
.map(async ({ at, pub }) => { .map(async ({ at, pub }) => {
const readStorageData = async (args) => { const readStorageData = async (args) => {
@ -539,7 +539,7 @@
const { epub } = at.put const { epub } = at.put
// Success! we've found our private data! // Success! we've found our private data!
err = null err = null
return { proof, at, key: { pub, priv, epriv, epub } } return { proof, at, pin, key: { pub, priv, epriv, epub } }
} catch (e) { } catch (e) {
err = 'Failed to decrypt private key!' err = 'Failed to decrypt private key!'
return return
@ -553,11 +553,11 @@
// now we have AES decrypted the private key, // now we have AES decrypted the private key,
// if we were successful, then that means we're logged in! // if we were successful, then that means we're logged in!
try { try {
await updatestorage(proof, key, pin)(key) await updatestorage(proof, key, newPin || pin)(key)
const user = Object.assign(key, { at, proof }) const user = Object.assign(key, { at, proof })
return await finalizelogin(alias, user, root, { pin }) return await finalizelogin(alias, user, root, { pin: newPin || pin })
} catch (e) { // TODO: right log message ? } catch (e) { // TODO: right log message ?
Gun.log('Failed to finalize login with new password!') Gun.log('Failed to finalize login with new password!')
const { err = '' } = e || {} const { err = '' } = e || {}