Skip to content

Commit 2bc7e92

Browse files
authored
Merge pull request #1218 from nextcloud-libraries/backport/1209/stable5
[stable5] fix: add check for validatePromise for passwordless environments
2 parents 93fcc44 + efa02c4 commit 2bc7e92

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function addPasswordConfirmationInterceptors(axios: AxiosInstance): void
128128

129129
INTERCEPTOR_INITIALIZED = true
130130

131-
let validatePromise: PromiseWithResolvers<void>
131+
let validatePromise: PromiseWithResolvers<void> | undefined
132132

133133
axios.interceptors.request.use(
134134
async (config) => {
@@ -175,6 +175,11 @@ export function addPasswordConfirmationInterceptors(axios: AxiosInstance): void
175175
return response
176176
}
177177

178+
if (validatePromise === undefined) {
179+
console.debug('Password confirmation not required', { response })
180+
return response
181+
}
182+
178183
console.debug('Password confirmation succeeded', { response })
179184
window.nc_lastLogin = Date.now() / 1000
180185
validatePromise.resolve()
@@ -186,6 +191,11 @@ export function addPasswordConfirmationInterceptors(axios: AxiosInstance): void
186191
throw error
187192
}
188193

194+
if (validatePromise === undefined) {
195+
console.debug('Password confirmation not required', { error })
196+
throw error
197+
}
198+
189199
console.debug('Password confirmation failed', { error })
190200
validatePromise.reject(error)
191201

0 commit comments

Comments
 (0)