diff --git a/packages/api/src/controllers/config.js b/packages/api/src/controllers/config.js index a0bb9517c..3ec18a0db 100644 --- a/packages/api/src/controllers/config.js +++ b/packages/api/src/controllers/config.js @@ -14,6 +14,7 @@ const connections = require('../controllers/connections'); const { getAuthProviderFromReq } = require('../auth/authProvider'); const { checkLicense, checkLicenseKey } = require('../utility/checkLicense'); const storage = require('./storage'); +const { getAuthProxyUrl } = require('../utility/authProxy'); const lock = new AsyncLock(); @@ -163,6 +164,19 @@ module.exports = { } }, + startTrial_meta: true, + async startTrial() { + try { + const resp = await axios.default.post(`${getAuthProxyUrl()}/trial-license`, { type: 'premium-trial', days: 30 }); + return resp.data; + } catch (err) { + return { + status: 'error', + message: err.messa, + }; + } + }, + updateSettings_meta: true, async updateSettings(values, req) { if (!hasPermission(`settings/change`, req)) return false; diff --git a/packages/api/src/utility/authProxy.js b/packages/api/src/utility/authProxy.js index d367c23bc..b83febd04 100644 --- a/packages/api/src/utility/authProxy.js +++ b/packages/api/src/utility/authProxy.js @@ -12,9 +12,14 @@ async function authProxyGetTokenFromCode(options) { function startTokenChecking(sid, callback) {} +function getAuthProxyUrl() { + return 'https://auth.dbgate.eu'; +} + module.exports = { isAuthProxySupported, authProxyGetRedirectUrl, authProxyGetTokenFromCode, startTokenChecking, + getAuthProxyUrl, }; diff --git a/packages/web/src/EnterLicensePage.svelte b/packages/web/src/EnterLicensePage.svelte index f56881343..b0f428ec0 100644 --- a/packages/web/src/EnterLicensePage.svelte +++ b/packages/web/src/EnterLicensePage.svelte @@ -10,12 +10,12 @@ import FormTextAreaField from './forms/FormTextAreaField.svelte'; import FormSubmit from './forms/FormSubmit.svelte'; import { apiCall } from './utility/api'; - + import FormStyledButton from './buttons/FormStyledButton.svelte'; + const config = useConfig(); const values = writable({ amoid: null, databaseServer: null }); - const params = new URLSearchParams(location.search); - const error = params.get('error'); + let errorMessage = ''; onMount(() => { const removed = document.getElementById('starting_dbgate_zero'); @@ -32,7 +32,7 @@
License
- +
-
- For trial license key, please contact us at sales@dbgate.eu +
+ { + errorMessage = ''; + const license = await apiCall('config/start-trial'); + if (license?.token) { + await apiCall('config/save-license-key', { licenseKey: license.token }); + internalRedirectTo('/index.html'); + } else { + errorMessage = license?.message || 'Error starting trial'; + } + }} + />
+ {#if errorMessage} +
{errorMessage}
+ {/if} + +
+ If you want to purchase Premium license, please contact us at sales@dbgate.eu +
@@ -117,7 +138,12 @@ font-size: larger; } - .trial-info { + .error { + margin: var(--dim-large-form-margin); + color: red; + } + + .purchase-info { margin: var(--dim-large-form-margin); }