Permalink
Browse files

fix(auth): return promise reject on request error

  • Loading branch information...
breakingrobot authored and pi0 committed Mar 29, 2018
1 parent ffd44de commit f2883c6574a4cfb0c522481293ca518de20f18f1
Showing with 15 additions and 10 deletions.
  1. 0 examples/demo/store/index.js
  2. +15 −10 lib/auth/auth.js
No changes.
@@ -89,9 +89,10 @@ export default class Auth {
return this.fetchUserOnce()
}
return Promise.resolve(this.strategy.mounted(...arguments)).catch(error =>
return Promise.resolve(this.strategy.mounted(...arguments)).catch(error => {
this.callOnError(error, { method: 'mounted' })
)
return Promise.reject(error)
})
}
loginWith (name, ...args) {
@@ -103,19 +104,21 @@ export default class Auth {
return Promise.resolve()
}
return this.wrapLogin(this.strategy.login(...arguments)).catch(error =>
return this.wrapLogin(this.strategy.login(...arguments)).catch(error => {
this.callOnError(error, { method: 'login' })
)
return Promise.reject(error)
})
}
fetchUser () {
if (!this.strategy.fetchUser) {
return Promise.resolve()
}
return Promise.resolve(this.strategy.fetchUser(...arguments)).catch(error =>
return Promise.resolve(this.strategy.fetchUser(...arguments)).catch(error => {
this.callOnError(error, { method: 'fetchUser' })
)
return Promise.reject(error)
})
}
logout () {
@@ -124,9 +127,10 @@ export default class Auth {
return Promise.resolve()
}
return Promise.resolve(this.strategy.logout(...arguments)).catch(error =>
return Promise.resolve(this.strategy.logout(...arguments)).catch(error => {
this.callOnError(error, { method: 'logout' })
)
return Promise.reject(error)
})
}
reset () {
@@ -136,9 +140,10 @@ export default class Auth {
return Promise.resolve()
}
return Promise.resolve(this.strategy.reset(...arguments)).catch(error =>
return Promise.resolve(this.strategy.reset(...arguments)).catch(error => {
this.callOnError(error, { method: 'reset' })
)
return Promise.reject(error)
})
}
// ---------------------------------------------------------------

0 comments on commit f2883c6

Please sign in to comment.