diff options
author | Sebastian <sebasjm@gmail.com> | 2023-03-15 07:21:26 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-03-15 07:22:03 -0300 |
commit | 41339c1db25306d8135084d24b1452a3ddd75dbb (patch) | |
tree | 930421098405de341162ff70bd390e666869c934 /packages/merchant-backoffice-ui/src/hooks/backend.ts | |
parent | 64c3cbc1dbc94c207bece0b9f6a399cdacd8dc22 (diff) | |
download | wallet-core-41339c1db25306d8135084d24b1452a3ddd75dbb.tar.xz |
check credetials on login
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/backend.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/backend.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/backend.ts b/packages/merchant-backoffice-ui/src/hooks/backend.ts index 6c4e5c176..93e95934e 100644 --- a/packages/merchant-backoffice-ui/src/hooks/backend.ts +++ b/packages/merchant-backoffice-ui/src/hooks/backend.ts @@ -139,6 +139,25 @@ interface useBackendBaseRequestType { type YesOrNo = "yes" | "no"; +export function useCredentialsChecker() { + const { request } = useApiContext(); + //check against instance details endpoint + //while merchant backend doesn't have a login endpoint + return async function testLogin( + instance: string, + token: string, + ): Promise<boolean> { + try { + const response = await request(instance, `/private/`, { + token, + }); + return true; + } catch (e) { + return false; + } + }; +} + /** * * @param root the request is intended to the base URL and no the instance URL |