[SDK] Authentication arguments inconsistency
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 82
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 4
Description
### Describe the Bug
Currently the Authentication via SDK has some inconsistencies. To be more precise the issue is with both operation arguments as well as defaults used for each one (for now I can confirm with `rest`, but also `auth` isn't clear):
# Description
I'll separate the Rest description form the Auth questions
## Rest
### `login`:
Code defaults to `cookie` (as it should)
https://github.com/directus/directus/blob/75c03bdd997714fde85148c39ad14bfa975e19c7/sdk/src/rest/commands/auth/login.ts#L24
While [docs say `json`](https://docs.directus.io/reference/authentication.html#login)
Screenshot
### `logout` and `refresh`
Both correctly defaults to `cookie`, no docs info (assuming `json` as login), but also the order of the arguments is inconsistent.
Which comes first, the chicken or the egg?
Also the `body: JSON.stringify(....)` is inconsistent, causing potential developer error in making the `refresh` work, but not the `logout` (and vice versa).
https://github.com/directus/directus/blob/75c03bdd997714fde85148c39ad14bfa975e19c7/sdk/src/rest/commands/auth/logout.ts#L12-L18
https://github.com/directus/directus/blob/75c03bdd997714fde85148c39ad14bfa975e19c7/sdk/src/rest/commands/auth/refresh.ts#L12-L21
## Auth
### `login`'s `mode` vs `logout` and `refresh`
In the auth's `login` the mode can be manually overwritten, but what would be the advantage if it cannot be also overwritten for `logout` and `refresh`? Wouldn't this cause inability for neither refreshing nor invalidating user's sessions if the developer erroneously edited the mode during login?
- `login`:
https://github.com/directus/directus/blob/75c03bdd997714fde85148c39ad14bfa975e19c7/sdk/src/auth/composable.ts#L131
- `logout`:
https://github.com/directus/directus/blob/75c03bdd997714fde85148c39ad14bfa975e19c7/sdk/src/auth/composable.ts#L167
- `refresh`:
https://github.com/directus/directus/blob/75c03bdd997714fde85148c39ad14bfa975e19c7/sdk/src/auth/composable.ts#L103
### To Reproduce
These issues were original discussed inside the [`nuxt-directus`#254](https://github.com/Intevel/nuxt-directus/issues/254) issue. But only now confirmed as I finally have noticed my error in the order of arguments for `refresh` and `logout`, and documentation declaring a different default.
### Directus Version
v10.10.5
### Hosting Strategy
Self-Hosted (Docker Image)
Contributor guide
Assessment
This issue has not been assessed yet.