Skip to content

Commit

Permalink
Improve password confirmation dialog
Browse files Browse the repository at this point in the history
Signed-off-by: julia.kirschenheuter <julia.kirschenheuter@nextcloud.com>
  • Loading branch information
JuliaKirschenheuter committed Oct 9, 2023
1 parent 2fda989 commit b8b339c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
10 changes: 5 additions & 5 deletions l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

msgid "Authentication required"
msgstr ""

msgid "Confirm"
msgstr ""

msgid "Failed to authenticate, please try again"
msgid "Confirm your password"
msgstr ""

msgid "Password"
Expand All @@ -17,5 +14,8 @@ msgstr ""
msgid "Password confirmation dialog already mounted"
msgstr ""

msgid "This action requires you to confirm your password"
msgid "This action needs authentication"
msgstr ""

msgid "Wrong password"
msgstr ""
25 changes: 12 additions & 13 deletions src/components/PasswordDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@
<NcPasswordField ref="field"
:value.sync="password"
:label="passwordLabelText"
:helper-text="showError ? errorText : ''"
:error="showError"
required
@keydown.enter="confirm" />

<NcNoteCard v-if="showError"
:show-alert="true">
<p>{{ errorText }}</p>
</NcNoteCard>

<NcButton type="primary"
class="dialog__button"
:disabled="!password"
:aria-label="confirmText"
@click="confirm">
{{ confirmText }}
Expand All @@ -57,7 +56,6 @@ import Vue from 'vue'
import axios from '@nextcloud/axios'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
import { generateUrl } from '@nextcloud/router'
import { DIALOG_ID } from '../globals.js'
Expand All @@ -71,7 +69,6 @@ export default Vue.extend({
components: {
NcButton,
NcModal,
NcNoteCard,
NcPasswordField,
},

Expand All @@ -80,10 +77,10 @@ export default Vue.extend({
password: '',
showError: false,
dialogId: DIALOG_ID,
titleText: t('Authentication required'),
subtitleText: t('This action requires you to confirm your password'),
titleText: t('Confirm your password'),
subtitleText: t('This action needs authentication'),
passwordLabelText: t('Password'),
errorText: t('Failed to authenticate, please try again'),
errorText: t('Wrong password'),
confirmText: t('Confirm'),
}
},
Expand All @@ -100,9 +97,11 @@ export default Vue.extend({

const url = generateUrl('/login/confirm')
try {
const { data } = await axios.post(url, { password: this.password })
window.nc_lastLogin = data.lastLogin
this.$emit('confirmed')
if (this.password !== '') {
const { data } = await axios.post(url, { password: this.password })
window.nc_lastLogin = data.lastLogin
this.$emit('confirmed')
}
} catch (e) {
this.showError = true
}
Expand Down

0 comments on commit b8b339c

Please sign in to comment.