Only clear cached credentials if autoauth fails
This commit is contained in:
parent
84ff20995b
commit
09d96efee7
1 changed files with 8 additions and 4 deletions
|
|
@ -147,10 +147,6 @@ const auth = (alias, pass) => {
|
||||||
}
|
}
|
||||||
isAuthing = true
|
isAuthing = true
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
lastAlias = ''
|
|
||||||
lastPass = ''
|
|
||||||
lastPair = null
|
|
||||||
logger.info('Reset cached credentials in case auth fails')
|
|
||||||
/** @type {Smith.SmithMsgAuth} */
|
/** @type {Smith.SmithMsgAuth} */
|
||||||
const msg = {
|
const msg = {
|
||||||
alias,
|
alias,
|
||||||
|
|
@ -169,6 +165,10 @@ const auth = (alias, pass) => {
|
||||||
const { ack } = msg
|
const { ack } = msg
|
||||||
|
|
||||||
if (ack.err) {
|
if (ack.err) {
|
||||||
|
lastAlias = ''
|
||||||
|
lastPass = ''
|
||||||
|
lastPair = null
|
||||||
|
logger.info('Auth unsuccessful, cached credentials cleared.')
|
||||||
rej(new Error(ack.err))
|
rej(new Error(ack.err))
|
||||||
} else if (ack.sea) {
|
} else if (ack.sea) {
|
||||||
lastAlias = alias
|
lastAlias = alias
|
||||||
|
|
@ -177,6 +177,10 @@ const auth = (alias, pass) => {
|
||||||
logger.info('Auth successful, credentials cached.')
|
logger.info('Auth successful, credentials cached.')
|
||||||
res(ack.sea)
|
res(ack.sea)
|
||||||
} else {
|
} else {
|
||||||
|
lastAlias = ''
|
||||||
|
lastPass = ''
|
||||||
|
lastPair = null
|
||||||
|
logger.info('Auth unsuccessful, cached credentials cleared.')
|
||||||
rej(new Error('Auth: ack.sea undefined'))
|
rej(new Error('Auth: ack.sea undefined'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue