save settings with password confirmation

This commit is contained in:
Simon Vieille
2025-04-14 22:44:00 +02:00
parent 31b330451c
commit b98bbd1053
2 changed files with 52 additions and 17 deletions
+10 -1
View File
@@ -13,13 +13,14 @@
<div <div
v-if="error" v-if="error"
id="error" id="error"
></div> >{{ error }}</div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { NcButton, NcLoadingIcon } from '@nextcloud/vue' import { NcButton, NcLoadingIcon } from '@nextcloud/vue'
import { ref } from 'vue' import { ref } from 'vue'
import { waitPasswordConfirmation } from '../../lib/setting.js'
const loading = ref(false) const loading = ref(false)
const error = ref(null) const error = ref(null)
@@ -62,6 +63,8 @@ const save = async () => {
} }
} }
waitPasswordConfirmation()
.then(() => {
for (let key in data) { for (let key in data) {
let value = data[key] let value = data[key]
@@ -81,6 +84,12 @@ const save = async () => {
}, },
}) })
} }
})
.catch(() => {
counter = 0
loading.value = false
error.value = null
})
} }
</script> </script>
+26
View File
@@ -0,0 +1,26 @@
const waitPasswordConfirmation = async () => {
let tries = 0
return new Promise((resolve, reject) => {
const execute = () => {
if (!OC.PasswordConfirmation.requiresPasswordConfirmation()) {
resolve()
return
}
OC.PasswordConfirmation.requirePasswordConfirmation(() => {})
if (++tries !== 10) {
setTimeout(() => {
execute()
}, 2000)
} else {
reject()
}
}
execute()
})
}
export { waitPasswordConfirmation }