Skip to content

Commit

Permalink
Replace password dialog with dialog from library
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 5, 2023
1 parent 529bce2 commit 6a64ad5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 59 deletions.
54 changes: 4 additions & 50 deletions core/src/OC/password-confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import _ from 'underscore'
import $ from 'jquery'
import moment from 'moment'
import { generateUrl } from '@nextcloud/router'
import { confirmPassword } from '@nextcloud/password-confirmation'

import OC from './index.js'

Expand All @@ -52,58 +53,11 @@ export default {

/**
* @param {Function} callback success callback function
* @param {object} options options
* @param {object} options options currently not used by confirmPassword
* @param {Function} rejectCallback error callback function
*/
requirePasswordConfirmation(callback, options, rejectCallback) {
options = typeof options !== 'undefined' ? options : {}
const defaults = {
title: t('core', 'Authentication required'),
text: t(
'core',
'This action requires you to confirm your password'
),
confirm: t('core', 'Confirm'),
label: t('core', 'Password'),
error: '',
}

const config = _.extend(defaults, options)

const self = this

if (this.requiresPasswordConfirmation()) {
OC.dialogs.prompt(
config.text,
config.title,
function(result, password) {
if (result && password !== '') {
self._confirmPassword(password, config)
} else if (_.isFunction(rejectCallback)) {
rejectCallback()
}
},
true,
config.label,
true
).then(function() {
const $dialog = $('.oc-dialog:visible')
$dialog.find('.ui-icon').remove()
$dialog.addClass('password-confirmation')
if (config.error !== '') {
const $error = $('<p></p>').addClass('msg warning').text(config.error)
$dialog.find('.oc-dialog-content').append($error)
}
const $buttonrow = $dialog.find('.oc-dialog-buttonrow')
$buttonrow.addClass('aside')

const $buttons = $buttonrow.find('button')
$buttons.eq(0).hide()
$buttons.eq(1).text(config.confirm)
})
}

this.callback = callback
confirmPassword().then(callback, rejectCallback)
},

_confirmPassword(password, config) {
Expand All @@ -123,7 +77,7 @@ export default {
}
},
error() {
config.error = t('core', 'Failed to authenticate, try again')
config.error = t('core', 'Failed to authenticate, please fill out your password')
OC.PasswordConfirmation.requirePasswordConfirmation(self.callback, config)
},
})
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

0 comments on commit 6a64ad5

Please sign in to comment.