summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/security_password.js85
-rw-r--r--settings/js/settings/personalInfo.js74
2 files changed, 85 insertions, 74 deletions
diff --git a/settings/js/security_password.js b/settings/js/security_password.js
new file mode 100644
index 00000000000..f7cb657c258
--- /dev/null
+++ b/settings/js/security_password.js
@@ -0,0 +1,85 @@
+/* global OC */
+
+/**
+ * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
+ * 2013, Morris Jobke <morris.jobke@gmail.com>
+ * 2016, Christoph Wurst <christoph@owncloud.com>
+ * 2017, Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * 2017, Thomas Citharel <tcit@tcit.fr>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ */
+
+$(document).ready(function () {
+ if($('#pass2').length) {
+ $('#pass2').showPassword().keyup();
+ }
+
+ var removeloader = function () {
+ setTimeout(function(){
+ if ($('.password-state').length > 0) {
+ $('.password-state').remove();
+ }
+ }, 5000)
+ };
+
+ $("#passwordbutton").click(function () {
+ if ($('#pass1').val() !== '' && $('#pass2').val() !== '') {
+ // Serialize the data
+ var post = $("#passwordform").serialize();
+ $('#passwordchanged').hide();
+ $('#passworderror').hide();
+ $("#passwordbutton").attr('disabled', 'disabled');
+ $("#passwordbutton").after("<span class='password-loading icon icon-loading-small-dark password-state'></span>");
+ $(".personal-show-label").hide();
+ // Ajax foo
+ $.post(OC.generateUrl('/settings/personal/changepassword'), post, function (data) {
+ if (data.status === "success") {
+ $("#passwordbutton").after("<span class='checkmark icon icon-checkmark password-state'></span>");
+ removeloader();
+ $('#pass1').val('');
+ $('#pass2').val('').change();
+ }
+ if (typeof(data.data) !== "undefined") {
+ OC.msg.finishedSaving('#password-error-msg', data);
+ } else {
+ OC.msg.finishedSaving('#password-error-msg',
+ {
+ 'status' : 'error',
+ 'data' : {
+ 'message' : t('settings', 'Unable to change password')
+ }
+ }
+ );
+ }
+ $(".personal-show-label").show();
+ $(".password-loading").remove();
+ $("#passwordbutton").removeAttr('disabled');
+ });
+ return false;
+ } else {
+ OC.msg.finishedSaving('#password-error-msg',
+ {
+ 'status' : 'error',
+ 'data' : {
+ 'message' : t('settings', 'Unable to change password')
+ }
+ }
+ );
+ return false;
+ }
+ });
+
+ $('#pass2').strengthify({
+ zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
+ titles: [
+ t('settings', 'Very weak password'),
+ t('settings', 'Weak password'),
+ t('settings', 'So-so password'),
+ t('settings', 'Good password'),
+ t('settings', 'Strong password')
+ ],
+ drawTitles: true,
+ $addAfter: $('input[name="newpassword-clone"]'),
+ });
+}); \ No newline at end of file
diff --git a/settings/js/settings/personalInfo.js b/settings/js/settings/personalInfo.js
index 2f7e1c386b5..c9da3c6ebe8 100644
--- a/settings/js/settings/personalInfo.js
+++ b/settings/js/settings/personalInfo.js
@@ -145,67 +145,6 @@ $(document).ready(function () {
$('#pass2').showPassword().keyup();
}
- var removeloader = function () {
- setTimeout(function(){
- if ($('.password-state').length > 0) {
- $('.password-state').remove();
- }
- }, 5000)
- };
-
- $("#passwordbutton").click(function () {
- var isIE8or9 = $('html').hasClass('lte9');
- // FIXME - TODO - once support for IE8 and IE9 is dropped
- // for IE8 and IE9 this will check additionally if the typed in password
- // is different from the placeholder, because in IE8/9 the placeholder
- // is simply set as the value to look like a placeholder
- if ($('#pass1').val() !== '' && $('#pass2').val() !== ''
- && !(isIE8or9 && $('#pass2').val() === $('#pass2').attr('placeholder'))) {
- // Serialize the data
- var post = $("#passwordform").serialize();
- $('#passwordchanged').hide();
- $('#passworderror').hide();
- $("#passwordbutton").attr('disabled', 'disabled');
- $("#passwordbutton").after("<span class='password-loading icon icon-loading-small-dark password-state'></span>");
- $(".personal-show-label").hide();
- // Ajax foo
- $.post(OC.generateUrl('/settings/personal/changepassword'), post, function (data) {
- if (data.status === "success") {
- $("#passwordbutton").after("<span class='checkmark icon icon-checkmark password-state'></span>");
- removeloader();
- $('#pass1').val('');
- $('#pass2').val('').change();
- }
- if (typeof(data.data) !== "undefined") {
- OC.msg.finishedSaving('#password-error-msg', data);
- } else {
- OC.msg.finishedSaving('#password-error-msg',
- {
- 'status' : 'error',
- 'data' : {
- 'message' : t('settings', 'Unable to change password')
- }
- }
- );
- }
- $(".personal-show-label").show();
- $(".password-loading").remove();
- $("#passwordbutton").removeAttr('disabled');
- });
- return false;
- } else {
- OC.msg.finishedSaving('#password-error-msg',
- {
- 'status' : 'error',
- 'data' : {
- 'message' : t('settings', 'Unable to change password')
- }
- }
- );
- return false;
- }
- });
-
var showVerifyDialog = function(dialog, howToVerify, verificationCode) {
var dialogContent = dialog.children('.verification-dialog-content');
dialogContent.children(".explainVerification").text(howToVerify);
@@ -417,19 +356,6 @@ $(document).ready(function () {
sendCropData();
});
- $('#pass2').strengthify({
- zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
- titles: [
- t('settings', 'Very weak password'),
- t('settings', 'Weak password'),
- t('settings', 'So-so password'),
- t('settings', 'Good password'),
- t('settings', 'Strong password')
- ],
- drawTitles: true,
- $addAfter: $('input[name="newpassword-clone"]'),
- });
-
// Load the big avatar
var user = OC.getCurrentUser();
$('#avatarform .avatardiv').avatar(user.uid, 145, true, null, function() {