fix: root user for dbs on arm

This commit is contained in:
Andras Bacsai 2022-12-19 09:52:50 +01:00
parent 06d40b8a81
commit a70adc5eb3
5 changed files with 51 additions and 46 deletions

View File

@ -1,31 +1,31 @@
import { FastifyPluginAsync } from 'fastify';
import { errorHandler, listSettings, version } from '../../../../lib/common';
import { errorHandler, isARM, listSettings, version } from '../../../../lib/common';
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
fastify.addHook('onRequest', async (request) => {
try {
await request.jwtVerify()
} catch(error) {
return
}
});
fastify.get('/', async (request) => {
const teamId = request.user?.teamId;
const settings = await listSettings()
try {
return {
ipv4: teamId ? settings.ipv4 : null,
ipv6: teamId ? settings.ipv6 : null,
version,
whiteLabeled: process.env.COOLIFY_WHITE_LABELED === 'true',
whiteLabeledIcon: process.env.COOLIFY_WHITE_LABELED_ICON,
isRegistrationEnabled: settings.isRegistrationEnabled,
}
} catch ({ status, message }) {
return errorHandler({ status, message })
}
});
fastify.addHook('onRequest', async (request) => {
try {
await request.jwtVerify();
} catch (error) {
return;
}
});
fastify.get('/', async (request) => {
const teamId = request.user?.teamId;
const settings = await listSettings();
try {
return {
ipv4: teamId ? settings.ipv4 : null,
ipv6: teamId ? settings.ipv6 : null,
version,
whiteLabeled: process.env.COOLIFY_WHITE_LABELED === 'true',
whiteLabeledIcon: process.env.COOLIFY_WHITE_LABELED_ICON,
isRegistrationEnabled: settings.isRegistrationEnabled,
isARM: isARM(process.arch)
};
} catch ({ status, message }) {
return errorHandler({ status, message });
}
});
};
export default root;

View File

@ -23,7 +23,8 @@ interface AppSession {
github: string | null,
gitlab: string | null,
},
pendingInvitations: Array<any>
pendingInvitations: Array<any>,
isARM: boolean
}
interface AddToast {
type?: "info" | "success" | "error",
@ -52,7 +53,8 @@ export const appSession: Writable<AppSession> = writable({
github: null,
gitlab: null
},
pendingInvitations: []
pendingInvitations: [],
isARM: false
});
export const disabledButton: Writable<boolean> = writable(false);
export const isDeploymentEnabled: Writable<boolean> = writable(false);

View File

@ -75,6 +75,7 @@
$appSession.version = baseSettings.version;
$appSession.whiteLabeled = baseSettings.whiteLabeled;
$appSession.whiteLabeledDetails.icon = baseSettings.whiteLabeledIcon;
$appSession.isARM = baseSettings.isARM;
$appSession.pendingInvitations = pendingInvitations;

View File

@ -1,6 +1,6 @@
<script lang="ts">
export let database: any;
import { status } from '$lib/store';
import { status, appSession } from '$lib/store';
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
import { t } from '$lib/translations';
import Explainer from '$lib/components/Explainer.svelte';
@ -56,7 +56,7 @@
placeholder={$t('forms.generated_automatically_after_start')}
id="rootUser"
name="rootUser"
value={database.rootUser}
value={$appSession.isARM ? 'root' : database.rootUser}
/>
</div>
<div class="grid grid-cols-2 items-center">

View File

@ -1,6 +1,6 @@
<script lang="ts">
export let database: any;
import { status } from '$lib/store';
import { status, appSession } from '$lib/store';
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
import { t } from '$lib/translations';
import Explainer from '$lib/components/Explainer.svelte';
@ -22,22 +22,24 @@
bind:value={database.defaultDatabase}
/>
</div>
<div class="grid grid-cols-2 items-center">
<label for="rootUser"
>Postgres User Password <Explainer
explanation="Could be changed while the database is running."
/></label
>
<CopyPasswordField
disabled={!$status.database.isRunning}
readonly={!$status.database.isRunning}
placeholder="Generated automatically after start"
isPasswordField
id="rootUserPassword"
name="rootUserPassword"
bind:value={database.rootUserPassword}
/>
</div>
{#if !$appSession.isARM}
<div class="grid grid-cols-2 items-center">
<label for="rootUser"
>Postgres User Password <Explainer
explanation="Could be changed while the database is running."
/></label
>
<CopyPasswordField
disabled={!$status.database.isRunning}
readonly={!$status.database.isRunning}
placeholder="Generated automatically after start"
isPasswordField
id="rootUserPassword"
name="rootUserPassword"
bind:value={database.rootUserPassword}
/>
</div>
{/if}
<div class="grid grid-cols-2 items-center">
<label for="dbUser">{$t('forms.user')}</label>
<CopyPasswordField