diff --git a/.prettierrc.json b/.prettierrc.json index 2519bad..f98859f 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,7 +1,15 @@ { - "importOrder": ["^[./]"], - "importOrderSeparation": true, - "tabWidth": 4, - "useTabs": false, - "semi": true + "importOrder": ["^[./]"], + "importOrderSeparation": true, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "overrides": [ + { + "files": "*.handlebar", + "options": { + "tabWidth": 2 + } + } + ] } diff --git a/templates/authorizeRequest.handlebar b/templates/authorizeRequest.handlebar index dcff0ea..4f39dfc 100644 --- a/templates/authorizeRequest.handlebar +++ b/templates/authorizeRequest.handlebar @@ -1,8 +1,8 @@ - - + + Authorize Request @@ -31,10 +31,56 @@ } } } + + function sendPostRequest(permissions) { + const url = '/requests/{{record.id}}'; + const password = document.getElementById('password').value; + let callbackUrl; + {{#if callbackUrl}} + callbackUrl = '{{callbackUrl}}'; + {{/if}} + const data = { + permissions, + password, + }; + + fetch(url, { + method: 'POST', // or 'PUT' + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(data), + }) + .then((response) => response.json()) + .then((data) => { + console.log('Success:', data); + + if (data.error) { + document.getElementById('error').innerText = data.error; + document.getElementById('error').classList.remove('hidden'); + return; + } + + // hide main content and show close message + document.getElementById('main').classList.add('hidden'); + document.getElementById('closeit').classList.remove('hidden'); + + // redirect to callback url + if (callbackUrl) { + const url = new URL(callbackUrl); + url.searchParams.append('pubkey', data.pubkey); + window.location.href = url.toString(); + } + }) + .catch((error) => { + console.error('Error:', error); + }); + }; + class="flex flex-col justify-center items-center min-h-screen bg-gray-100 dark:bg-neutral-800 text-neutrla-950 dark:text-neutral-50" + >

+ class="text-neutral-950 dark:text-neutral-50 text-lg font-semibold w-full" + > Do you want to allow this client to use account
- {{record.keyName}}? + {{ record.keyName }}?

- + {{#unless authenticated}}
@@ -79,12 +132,14 @@
@@ -101,10 +156,10 @@ - \ No newline at end of file +