mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-24 09:45:35 +08:00
feat: update secret when changed (#48)
Co-authored-by: kunish <17328586+kunish@users.noreply.github.com>
This commit is contained in:
parent
21e2b29159
commit
935908e0c1
@ -50,13 +50,17 @@ export default () => {
|
||||
const { form } = createForm<z.infer<typeof schema>>({
|
||||
extend: validator({ schema }),
|
||||
async onSubmit({ url, secret }) {
|
||||
const endpointFromHistory = endpointList().find(
|
||||
(history) => history.url === url && history.secret === secret,
|
||||
)
|
||||
const i = endpointList().findIndex((history) => history.url === url)
|
||||
|
||||
if (endpointFromHistory) {
|
||||
onSetupSuccess(endpointFromHistory.id)
|
||||
if (i > -1) {
|
||||
const { id, secret: oldSecret } = endpointList()[i]
|
||||
|
||||
if (secret !== oldSecret && !(await checkEndpoint(url, secret))) {
|
||||
endpointList()[i].secret = secret
|
||||
setEndpointList(endpointList())
|
||||
}
|
||||
|
||||
onSetupSuccess(id)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user