-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add change password dialog and logout function
- Loading branch information
Showing
19 changed files
with
251 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<p :class="[$style.alert, classes]"> | ||
{{ text }} | ||
</p> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed } from 'vue'; | ||
import { Color, useThemeStyles } from '@composables'; | ||
import { ClassNames } from '@utils'; | ||
const props = withDefaults( | ||
defineProps<{ | ||
class?: ClassNames; | ||
text: string; | ||
color?: Color; | ||
}>(), | ||
{ | ||
color: 'primary' | ||
} | ||
); | ||
const classes = computed(() => props.class); | ||
const theme = useThemeStyles(() => props.color); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.alert { | ||
background: v-bind('theme.color.base'); | ||
color: v-bind('theme.text.base'); | ||
padding: 4px 6px; | ||
font-weight: var(--font-weight-l); | ||
font-size: var(--font-size-xs); | ||
border-radius: var(--border-radius-m); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<div :class="$style.fields"> | ||
<h3 :class="$style.title">{{ title }}</h3> | ||
<slot /> | ||
<Button :class="$style.btn" :text="submitLabel ?? title" color="success" @click="emit('submit')" /> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import Button from '@components/base/button/Button.vue'; | ||
const emit = defineEmits<{ | ||
(e: 'submit'): void; | ||
}>(); | ||
defineProps<{ | ||
title: string; | ||
submitLabel?: string; | ||
}>(); | ||
</script> | ||
<style lang="scss" module> | ||
.fields { | ||
display: flex; | ||
flex-direction: column; | ||
width: 200px; | ||
gap: 8px; | ||
padding-top: 8px; | ||
.title { | ||
text-align: center; | ||
font-weight: var(--font-weight-l); | ||
font-style: var(--font-size-m); | ||
padding-bottom: 8px; | ||
} | ||
.btn { | ||
text-align: center; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/app/pages/navigation/tools/change-password/ChangePasswordButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<ContextMenuButton icon="key-2-line" :text="t('auth.changePassword')" @click="showChangePasswordDialog = true" /> | ||
<ChangePasswordDialog :open="showChangePasswordDialog" @close="showChangePasswordDialog = false" /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import ContextMenuButton from '@components/base/context-menu/ContextMenuButton.vue'; | ||
import ChangePasswordDialog from './ChangePasswordDialog.vue'; | ||
const { t } = useI18n(); | ||
const showChangePasswordDialog = ref(false); | ||
</script> |
67 changes: 67 additions & 0 deletions
67
src/app/pages/navigation/tools/change-password/ChangePasswordDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<Dialog :open="open" @close="emit('close')"> | ||
<InputFields :title="t('auth.changePassword')" @submit="submit"> | ||
<InputField v-model="currentPassword" :label="t('auth.currentPassword')" type="password" /> | ||
<InputField v-model="newPassword" :label="t('auth.newPassword')" type="password" show-password-strength /> | ||
<Alert v-if="state === 'errored'" :text="t('auth.errors.changePassword')" color="danger" /> | ||
</InputFields> | ||
</Dialog> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import Alert from '@components/base/alert/Alert.vue'; | ||
import Dialog from '@components/base/dialog/Dialog.vue'; | ||
import InputField from '@components/base/input-field/InputField.vue'; | ||
import InputFields from '@components/base/input-field/InputFields.vue'; | ||
import { useStorage } from '@storage/index'; | ||
const emit = defineEmits<{ | ||
(e: 'close'): void; | ||
}>(); | ||
defineProps<{ | ||
open: boolean; | ||
}>(); | ||
const { t } = useI18n(); | ||
const { updatePassword } = useStorage(); | ||
const currentPassword = ref(import.meta.env.APP_PASSWORD ?? ''); | ||
const newPassword = ref(''); | ||
const state = ref<'idle' | 'loading' | 'errored'>('idle'); | ||
const submit = async () => { | ||
if (state.value !== 'loading') { | ||
if (await updatePassword(currentPassword.value, newPassword.value)) { | ||
currentPassword.value = ''; | ||
newPassword.value = ''; | ||
state.value = 'idle'; | ||
emit('close'); | ||
} else { | ||
state.value = 'errored'; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.fields { | ||
display: flex; | ||
flex-direction: column; | ||
width: 200px; | ||
gap: 8px; | ||
padding-top: 8px; | ||
.title { | ||
text-align: center; | ||
font-weight: var(--font-weight-xl); | ||
font-style: var(--font-size-m); | ||
} | ||
.btn { | ||
text-align: center; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.