mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 23:53:57 +00:00
database login support
This commit is contained in:
@@ -21,7 +21,13 @@ function unauthorizedResponse(req, res, text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function authMiddleware(req, res, next) {
|
function authMiddleware(req, res, next) {
|
||||||
const SKIP_AUTH_PATHS = ['/config/get', '/auth/oauth-token', '/auth/login', '/stream'];
|
const SKIP_AUTH_PATHS = [
|
||||||
|
'/config/get',
|
||||||
|
'/auth/oauth-token',
|
||||||
|
'/auth/login',
|
||||||
|
'/stream',
|
||||||
|
'storage/get-connections-for-login-page',
|
||||||
|
];
|
||||||
|
|
||||||
// console.log('********************* getAuthProvider()', getAuthProvider());
|
// console.log('********************* getAuthProvider()', getAuthProvider());
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,32 @@
|
|||||||
import { apiCall, enableApi } from './utility/api';
|
import { apiCall, enableApi } from './utility/api';
|
||||||
import { useConfig } from './utility/metadataLoaders';
|
import { useConfig } from './utility/metadataLoaders';
|
||||||
import ErrorInfo from './elements/ErrorInfo.svelte';
|
import ErrorInfo from './elements/ErrorInfo.svelte';
|
||||||
|
import FormSelectField from './forms/FormSelectField.svelte';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
import FormProviderCore from './forms/FormProviderCore.svelte';
|
||||||
|
|
||||||
export let isAdminPage;
|
export let isAdminPage;
|
||||||
|
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
|
|
||||||
|
let availableConnections = null;
|
||||||
|
|
||||||
|
const values = writable({});
|
||||||
|
|
||||||
|
async function loadAvailableServers() {
|
||||||
|
availableConnections = await apiCall('storage/get-connections-for-login-page');
|
||||||
|
if (availableConnections?.length > 0) {
|
||||||
|
values.set({ databaseServer: availableConnections[0].id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const removed = document.getElementById('starting_dbgate_zero');
|
const removed = document.getElementById('starting_dbgate_zero');
|
||||||
if (removed) removed.remove();
|
if (removed) removed.remove();
|
||||||
|
|
||||||
|
if (!isAdminPage) {
|
||||||
|
loadAvailableServers();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -28,7 +46,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="heading">Log In</div>
|
<div class="heading">Log In</div>
|
||||||
<FormProvider>
|
<FormProviderCore {values}>
|
||||||
|
{#if !isAdminPage && availableConnections}
|
||||||
|
<FormSelectField
|
||||||
|
label="Database server"
|
||||||
|
name="databaseServer"
|
||||||
|
isNative
|
||||||
|
options={availableConnections.map(conn => ({ value: conn.id, label: conn.label }))}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if !isAdminPage}
|
{#if !isAdminPage}
|
||||||
<FormTextField label="Username" name="login" autocomplete="username" saveOnInput />
|
<FormTextField label="Username" name="login" autocomplete="username" saveOnInput />
|
||||||
{/if}
|
{/if}
|
||||||
@@ -67,7 +94,7 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</FormProvider>
|
</FormProviderCore>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user