Skip to content

Commit f2883c6

Browse files
Tony BRIETpi0
authored andcommitted
fix(auth): return promise reject on request error
1 parent ffd44de commit f2883c6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

examples/demo/store/index.js

Whitespace-only changes.

lib/auth/auth.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ export default class Auth {
8989
return this.fetchUserOnce()
9090
}
9191

92-
return Promise.resolve(this.strategy.mounted(...arguments)).catch(error =>
92+
return Promise.resolve(this.strategy.mounted(...arguments)).catch(error => {
9393
this.callOnError(error, { method: 'mounted' })
94-
)
94+
return Promise.reject(error)
95+
})
9596
}
9697

9798
loginWith (name, ...args) {
@@ -103,19 +104,21 @@ export default class Auth {
103104
return Promise.resolve()
104105
}
105106

106-
return this.wrapLogin(this.strategy.login(...arguments)).catch(error =>
107+
return this.wrapLogin(this.strategy.login(...arguments)).catch(error => {
107108
this.callOnError(error, { method: 'login' })
108-
)
109+
return Promise.reject(error)
110+
})
109111
}
110112

111113
fetchUser () {
112114
if (!this.strategy.fetchUser) {
113115
return Promise.resolve()
114116
}
115117

116-
return Promise.resolve(this.strategy.fetchUser(...arguments)).catch(error =>
118+
return Promise.resolve(this.strategy.fetchUser(...arguments)).catch(error => {
117119
this.callOnError(error, { method: 'fetchUser' })
118-
)
120+
return Promise.reject(error)
121+
})
119122
}
120123

121124
logout () {
@@ -124,9 +127,10 @@ export default class Auth {
124127
return Promise.resolve()
125128
}
126129

127-
return Promise.resolve(this.strategy.logout(...arguments)).catch(error =>
130+
return Promise.resolve(this.strategy.logout(...arguments)).catch(error => {
128131
this.callOnError(error, { method: 'logout' })
129-
)
132+
return Promise.reject(error)
133+
})
130134
}
131135

132136
reset () {
@@ -136,9 +140,10 @@ export default class Auth {
136140
return Promise.resolve()
137141
}
138142

139-
return Promise.resolve(this.strategy.reset(...arguments)).catch(error =>
143+
return Promise.resolve(this.strategy.reset(...arguments)).catch(error => {
140144
this.callOnError(error, { method: 'reset' })
141-
)
145+
return Promise.reject(error)
146+
})
142147
}
143148

144149
// ---------------------------------------------------------------

0 commit comments

Comments
 (0)