Cant catch the OTP code required error
Attacler opened this issue ยท 5 comments
Version
nuxt-directus 5.1.3
nuxt: 3.4.2
Steps to reproduce
- make some kind of login page that calls login from useDirectusAuth
- enable OTP on your account
- Try to login with only your email/password
What is Expected?
The login method should also return the raw response of what Directus gives back.
That way we can actually capture this response.
What is actually happening?
The following is returned:
eDirectus.mjs:26 [Directus Error]: FetchError: (401 Unauthorized (http://localhost:8055/auth/login))
(anonymous) @ useDirectus.mjs:26
await in (anonymous) (async)
login @ useDirectusAuth.mjs:58
login @ user.ts:22
(anonymous) @ pinia.mjs:1365
tryLogin @ login.vue:21
(anonymous) @ chunk-LGAZO65B.js:9171
callWithErrorHandling @ chunk-LGAZO65B.js:1580
callWithAsyncErrorHandling @ chunk-LGAZO65B.js:1588
invoker @ chunk-LGAZO65B.js:8198
While the Directus API returns:
The official app also uses this way of checking if OTP is enabled, because you never know if OTP is required on the account.
After some digging i saw that useDirectus.ts only returns the status + statusText.
Maybe its an idea to also return the response of Directus here so we can check cases like this?
When we rework the auth module to manage token refresh
@casualmatt @Intevel is there any workaround for the time being?
Its also usefull to catch things like "email is not unique" during registration or other cases.
@Attacler I will fix this today, @casualmatt I know it will be to add this to the auth rework but this is a needed feature.