mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
enhance: save certificate before renew #723
This commit is contained in:
parent
e6998feca4
commit
f4c17f0c65
9 changed files with 23 additions and 18 deletions
|
@ -98,12 +98,9 @@ func IssueCert(c *gin.Context) {
|
|||
|
||||
// block, until errChan closes
|
||||
for err = range errChan {
|
||||
|
||||
log.Error(err)
|
||||
|
||||
// Save logs to db
|
||||
log.Exit()
|
||||
|
||||
err = ws.WriteJSON(IssueCertResponse{
|
||||
Status: Error,
|
||||
Message: err.Error(),
|
||||
|
@ -112,7 +109,6 @@ func IssueCert(c *gin.Context) {
|
|||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ export function detailRender(args: CustomRender) {
|
|||
return args.text
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line sonarjs/no-ignored-exceptions
|
||||
// eslint-disable-next-line sonarjs/no-ignored-exceptions,unused-imports/no-unused-vars
|
||||
catch (e) {
|
||||
return args.text
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import VOtpInput from 'vue3-otp-input'
|
|||
const emit = defineEmits(['onComplete'])
|
||||
|
||||
const data = defineModel<string>()
|
||||
|
||||
// eslint-disable-next-line vue/require-typed-ref
|
||||
const refOtp = ref()
|
||||
|
||||
function onComplete(value: string) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { UseClipboard } from '@vueuse/components'
|
||||
import { $gettext } from '../../gettext'
|
||||
|
||||
const props = defineProps<{
|
||||
value: string
|
||||
|
|
|
@ -61,7 +61,7 @@ function add(preset: any = undefined) {
|
|||
modifyMode.value = true
|
||||
}
|
||||
|
||||
const table = ref()
|
||||
const table = useTemplateRef('table')
|
||||
const inTrash = ref(false)
|
||||
const getParams = reactive(props.getParams ?? {})
|
||||
|
||||
|
|
|
@ -40,17 +40,24 @@ onMounted(() => {
|
|||
|
||||
const router = useRouter()
|
||||
const errors = ref({}) as Ref<Record<string, string>>
|
||||
function save() {
|
||||
cert.save(data.value.id, data.value).then(r => {
|
||||
|
||||
async function save() {
|
||||
try {
|
||||
const r = await cert.save(data.value.id, data.value)
|
||||
data.value = r
|
||||
message.success($gettext('Save successfully'))
|
||||
router.push(`/certificates/${r.id}`)
|
||||
errors.value = {}
|
||||
}).catch(e => {
|
||||
message.success($gettext('Save successfully'))
|
||||
await router.push(`/certificates/${r.id}`)
|
||||
}
|
||||
// eslint-disable-next-line ts/no-explicit-any
|
||||
catch (e: any) {
|
||||
errors.value = e.errors
|
||||
message.error($gettext(e?.message ?? 'Server error'))
|
||||
})
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
provide('saveCert', save)
|
||||
|
||||
const log = computed(() => {
|
||||
const logs = data.value.log?.split('\n')
|
||||
|
|
|
@ -13,15 +13,17 @@ const emit = defineEmits<{
|
|||
|
||||
const modalVisible = ref(false)
|
||||
const modalClosable = ref(true)
|
||||
const refObtainCertLive = useTemplateRef('refObtainCertLive')
|
||||
const saveCert = inject<() => Promise<void>>('saveCert')!
|
||||
|
||||
const refObtainCertLive = ref()
|
||||
async function issueCert() {
|
||||
await saveCert()
|
||||
|
||||
function issueCert() {
|
||||
modalVisible.value = true
|
||||
|
||||
const { name, domains, key_type } = props.options
|
||||
|
||||
refObtainCertLive.value.issue_cert(name, domains, key_type).then(() => {
|
||||
refObtainCertLive.value?.issue_cert(name!, domains, key_type).then(() => {
|
||||
message.success($gettext('Renew successfully'))
|
||||
emit('renewed')
|
||||
})
|
||||
|
|
|
@ -3,7 +3,6 @@ import type { AutoCertOptions } from '@/api/auto_cert'
|
|||
import { PrivateKeyTypeList } from '@/constants'
|
||||
import ACMEUserSelector from '@/views/certificate/ACMEUserSelector.vue'
|
||||
import DNSChallenge from '@/views/site/cert/components/DNSChallenge.vue'
|
||||
import { $gettext } from '../../../../gettext'
|
||||
|
||||
const props = defineProps<{
|
||||
hideNote?: boolean
|
||||
|
|
|
@ -4,7 +4,7 @@ import "github.com/go-acme/lego/v4/certcrypto"
|
|||
|
||||
func GetKeyType(keyType certcrypto.KeyType) certcrypto.KeyType {
|
||||
switch keyType {
|
||||
case certcrypto.RSA2048, certcrypto.RSA3072, certcrypto.RSA4096,
|
||||
case certcrypto.RSA2048, certcrypto.RSA3072, certcrypto.RSA4096, certcrypto.RSA8192,
|
||||
certcrypto.EC256, certcrypto.EC384:
|
||||
return keyType
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue