]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use the existing prompt
authorJoas Schilling <coding@schilljs.com>
Thu, 17 Nov 2016 09:36:39 +0000 (10:36 +0100)
committerLukas Reschke <lukas@statuscode.ch>
Fri, 18 Nov 2016 11:10:51 +0000 (12:10 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
core/css/jquery.ocdialog.css
core/css/styles.css
core/js/js.js

index 0e46ff2015242e9e2f76a2740c7f05b82c4769d6..d1a426945897f3c349c2bad753307b3e9fc6cb11 100644 (file)
@@ -22,7 +22,6 @@
 .oc-dialog-buttonrow {
        display: block;
        background: transparent;
-       position: absolute;
        right: 0;
        bottom: 0;
        padding: 10px;
index 6e0156d2238f134dca541099904187d28278596c..f0c4c4f33ff47bf7a6b03a7e64a128acfb812f2f 100644 (file)
@@ -983,38 +983,3 @@ fieldset.warning legend + p, fieldset.update legend + p {
    opacity: 0;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
 }
-
-#sudo-login-background {
-       position: absolute;
-       width: 100%;
-       height: 100%;
-       background-color: #1d2d44;
-       opacity:0.4;
-       z-index: 999;
-}
-
-#sudo-login-form {
-       position: absolute;
-       top: 45%;
-       left: 40%;
-       border: 1px solid #e9322d;
-       color: #e9322d;
-       font-weight: bold;
-       z-index: 1000;
-       background: #e4b9c0;
-       border-radius: 10px;
-       opacity:1;
-       padding: 25px;
-}
-
-#sudo-login-form .question {
-       width: 250px;
-}
-
-#sudo-login-form .confirm {
-       position: relative;
-       right: 32px;
-       border: none;
-       opacity: .3;
-       background-color: transparent;
-}
index 4579fe394af32123a809203b428f1fb4eb59bbad..64c7dda31e2979c64a967ff81b300cef44b99a92 100644 (file)
@@ -1517,31 +1517,15 @@ function initCore() {
 }
 
 OC.PasswordConfirmation = {
-       $form: null,
-       $background: null,
-       $input: null,
-       $submit: null,
        callback: null,
 
        init: function() {
-               var self = this;
-               this.$form = $('#sudo-login-form');
-               this.$background = $('#sudo-login-background');
-               this.$input = this.$form.find('.question');
-               this.$submit = this.$form.find('.confirm');
-
-               this.$background.on('click', _.bind(this._fadeOut, this));
                $('.password-confirm-required').on('click', _.bind(this.requirePasswordConfirmation, this));
-               this.$submit.on('click', _.bind(this._submitPasswordConfirmation, this));
-               this.$input.keyup(function(e) {
-                       if (e.keyCode === 13) {
-                               self._submitPasswordConfirmation();
-                       }
-               });
        },
 
        requiresPasswordConfirmation: function() {
                var timeSinceLogin = moment.now() - nc_lastLogin * 1000;
+               return timeSinceLogin > 10 * 1000; // 30 minutes
                return timeSinceLogin > 30 * 60 * 1000; // 30 minutes
        },
 
@@ -1549,50 +1533,56 @@ OC.PasswordConfirmation = {
         * @param {function} callback
         */
        requirePasswordConfirmation: function(callback) {
+               var self = this;
+
                if (this.requiresPasswordConfirmation()) {
-                       this.$form.removeClass('hidden');
-                       this.$background.removeClass('hidden');
-                       this.$input.val('');
+                       OC.dialogs.prompt(
+                               t(
+                                       'core',
+                                       'This action requires you to confirm your password'
+                               ),
+                               t('core','Authentication required'),
+                               function (result, password) {
+                                       if (result && password !== '') {
+                                               self._confirmPassword(password);
+                                       }
+                               },
+                               true,
+                               t('core','Password'),
+                               true
+                       ).then(function() {
+                               var $dialog = $('.oc-dialog:visible');
+                               $dialog.find('.ui-icon').remove();
+
+                               var $buttons = $dialog.find('button');
+                               $buttons.eq(0).text(t('core', 'Cancel'));
+                               $buttons.eq(1).text(t('core', 'Confirm'));
+                       });
                }
 
                this.callback = callback;
        },
 
-       _submitPasswordConfirmation: function() {
+       _confirmPassword: function(password) {
                var self = this;
 
-               self.$submit.removeClass('icon-confirm').addClass('icon-loading-small');
-
                $.ajax({
                        url: OC.generateUrl('/login/confirm'),
                        data: {
-                               password: this.$input.val()
+                               password: password
                        },
                        type: 'POST',
                        success: function(response) {
-                               self.$input.val('');
                                nc_lastLogin = response.lastLogin;
-                               self.$submit.addClass('icon-confirm').removeClass('icon-loading-small');
-
-                               self.$form.addClass('hidden');
-                               self.$background.addClass('hidden');
 
                                if (_.isFunction(self.callback)) {
                                        self.callback();
                                }
                        },
                        error: function() {
-                               self.$input.val('');
                                OC.Notification.showTemporary(t('core', 'Failed to authenticate, try again'));
-                               self.$submit.addClass('icon-confirm').removeClass('icon-loading-small');
                        }
                });
-       },
-
-       _fadeOut: function() {
-               this.$form.addClass('hidden');
-               this.$background.addClass('hidden');
-               this.$input.value = '';
        }
 };