fix: Renew certificates

This commit is contained in:
Andras Bacsai
2022-05-03 11:40:02 +02:00
parent 40da3ff9fe
commit 8b813fb07a
5 changed files with 80 additions and 7 deletions

View File

@@ -111,6 +111,14 @@
loading.save = false;
}
}
async function renewCerts() {
try {
toast.push('Renewing certificates...');
return await post(`/settings/renew.json`, {});
} catch ({ error }) {
return errorNotification(error);
}
}
</script>
<div class="flex space-x-1 p-6 font-bold">
@@ -219,6 +227,19 @@
on:click={() => changeSettings('isAutoUpdateEnabled')}
/>
</div>
<div class="grid grid-cols-2 items-center">
<div class="flex flex-col">
<div class="pt-2 text-base font-bold text-stone-100">
Renew SSL Certificates manually
</div>
<Explainer text="It will check and renew certificates manually" />
</div>
<div class="mx-auto ">
<button class="w-32 bg-coollabs hover:bg-coollabs-100" on:click={renewCerts}
>SSL renew manually</button
>
</div>
</div>
{/if}
</div>
</form>

View File

@@ -0,0 +1,26 @@
import { getUserDetails } from '$lib/common';
import { ErrorHandler } from '$lib/database';
import { renewSSLCerts } from '$lib/letsencrypt';
import { t } from '$lib/translations';
import type { RequestHandler } from '@sveltejs/kit';
export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
if (teamId !== '0')
return {
status: 401,
body: {
message: t.get('setting.permission_denied')
}
};
if (status === 401) return { status, body };
try {
renewSSLCerts();
return {
status: 201
};
} catch (error) {
return ErrorHandler(error);
}
};