wire up force reset password action

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-19 13:57:54 +02:00
parent 728bbe473a
commit 5d60a0b1f6
3 changed files with 14 additions and 5 deletions

View File

@ -108,8 +108,11 @@
</div>
</div>
<div class="regenerate">
<ActionButton size="S" icon="Refresh" quiet
>Regenerate password</ActionButton
<ActionButton
size="S"
icon="Refresh"
quiet
on:click={resetPasswordModal.show}>Force password reset</ActionButton
>
</div>
</div>
@ -161,7 +164,10 @@
/>
</Modal>
<Modal bind:this={resetPasswordModal}>
<ForceResetPasswordModal user={$userFetch.data} />
<ForceResetPasswordModal
user={$userFetch.data}
on:update={userFetch.refresh}
/>
</Modal>
<style>

View File

@ -1,17 +1,21 @@
<script>
import { createEventDispatcher } from "svelte"
import { ModalContent, Body, Input, notifications } from "@budibase/bbui"
import { users } from "stores/portal"
const dispatch = createEventDispatcher()
export let user
const password = Math.random().toString(36).substr(2, 20)
async function resetPassword() {
const res = await users.save.create({ ...user, password })
const res = await users.save({ ...user, password })
if (res.status) {
notifications.error(res.message)
} else {
notifications.success("Password reset.")
dispatch("update")
}
}
</script>

View File

@ -1,7 +1,6 @@
<script>
import { createEventDispatcher } from "svelte"
import { Body, Select, ModalContent, notifications } from "@budibase/bbui"
import { fetchData } from "helpers"
import { users } from "stores/portal"
export let app