mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 09:24:00 +00:00
trial support
This commit is contained in:
@@ -14,6 +14,7 @@ const connections = require('../controllers/connections');
|
|||||||
const { getAuthProviderFromReq } = require('../auth/authProvider');
|
const { getAuthProviderFromReq } = require('../auth/authProvider');
|
||||||
const { checkLicense, checkLicenseKey } = require('../utility/checkLicense');
|
const { checkLicense, checkLicenseKey } = require('../utility/checkLicense');
|
||||||
const storage = require('./storage');
|
const storage = require('./storage');
|
||||||
|
const { getAuthProxyUrl } = require('../utility/authProxy');
|
||||||
|
|
||||||
const lock = new AsyncLock();
|
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,
|
updateSettings_meta: true,
|
||||||
async updateSettings(values, req) {
|
async updateSettings(values, req) {
|
||||||
if (!hasPermission(`settings/change`, req)) return false;
|
if (!hasPermission(`settings/change`, req)) return false;
|
||||||
|
|||||||
@@ -12,9 +12,14 @@ async function authProxyGetTokenFromCode(options) {
|
|||||||
|
|
||||||
function startTokenChecking(sid, callback) {}
|
function startTokenChecking(sid, callback) {}
|
||||||
|
|
||||||
|
function getAuthProxyUrl() {
|
||||||
|
return 'https://auth.dbgate.eu';
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isAuthProxySupported,
|
isAuthProxySupported,
|
||||||
authProxyGetRedirectUrl,
|
authProxyGetRedirectUrl,
|
||||||
authProxyGetTokenFromCode,
|
authProxyGetTokenFromCode,
|
||||||
startTokenChecking,
|
startTokenChecking,
|
||||||
|
getAuthProxyUrl,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
import FormTextAreaField from './forms/FormTextAreaField.svelte';
|
import FormTextAreaField from './forms/FormTextAreaField.svelte';
|
||||||
import FormSubmit from './forms/FormSubmit.svelte';
|
import FormSubmit from './forms/FormSubmit.svelte';
|
||||||
import { apiCall } from './utility/api';
|
import { apiCall } from './utility/api';
|
||||||
|
import FormStyledButton from './buttons/FormStyledButton.svelte';
|
||||||
|
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const values = writable({ amoid: null, databaseServer: null });
|
const values = writable({ amoid: null, databaseServer: null });
|
||||||
|
|
||||||
const params = new URLSearchParams(location.search);
|
let errorMessage = '';
|
||||||
const error = params.get('error');
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const removed = document.getElementById('starting_dbgate_zero');
|
const removed = document.getElementById('starting_dbgate_zero');
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="heading">License</div>
|
<div class="heading">License</div>
|
||||||
<FormTextAreaField label="License key" name="licenseKey" rows={5} />
|
<FormTextAreaField label="Enter your license key" name="licenseKey" rows={5} />
|
||||||
|
|
||||||
<div class="submit">
|
<div class="submit">
|
||||||
<FormSubmit
|
<FormSubmit
|
||||||
@@ -45,10 +45,31 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='trial-info'>
|
<div class="submit">
|
||||||
For trial license key, please contact us at <Link href="mailto:sales@dbgate.eu">sales@dbgate.eu</Link>
|
<FormStyledButton
|
||||||
|
value="Start 30-day trial"
|
||||||
|
on:click={async e => {
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if errorMessage}
|
||||||
|
<div class="error">{errorMessage}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="purchase-info">
|
||||||
|
If you want to purchase Premium license, please contact us at <Link href="mailto:sales@dbgate.eu"
|
||||||
|
>sales@dbgate.eu</Link
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -117,7 +138,12 @@
|
|||||||
font-size: larger;
|
font-size: larger;
|
||||||
}
|
}
|
||||||
|
|
||||||
.trial-info {
|
.error {
|
||||||
|
margin: var(--dim-large-form-margin);
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.purchase-info {
|
||||||
margin: var(--dim-large-form-margin);
|
margin: var(--dim-large-form-margin);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user