aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/hooks/backend.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/backend.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/backend.ts19
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