feat(placetel): Implement app structure with authentication

This commit is contained in:
Faruk AYDIN
2023-10-05 17:26:39 +02:00
parent 57bba90091
commit 712bee297a
6 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import verifyCredentials from './verify-credentials';
import isStillVerified from './is-still-verified';
export default {
fields: [
{
key: 'apiToken',
label: 'API Token',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
placeholder: null,
description: 'Placetel API Token of your account.',
clickToCopy: false,
},
],
verifyCredentials,
isStillVerified,
};

View File

@@ -0,0 +1,9 @@
import { IGlobalVariable } from '@automatisch/types';
import verifyCredentials from './verify-credentials';
const isStillVerified = async ($: IGlobalVariable) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -0,0 +1,11 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
const { data } = await $.http.get('/v2/me');
await $.auth.set({
screenName: `${data.name} @ ${data.company}`,
});
};
export default verifyCredentials;