From 3a6f7d9b366f31e1295b332d7d63874afb809dff Mon Sep 17 00:00:00 2001 From: mcrosson Date: Mon, 16 Jul 2018 17:02:55 +0000 Subject: [PATCH 1/6] Fixup docker rename calls (addresses #244) --- rpc.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpc.js b/rpc.js index 69d84b6dd..b13d1c9ad 100644 --- a/rpc.js +++ b/rpc.js @@ -7,6 +7,8 @@ var Nacl = require("tweetnacl"); /* globals process */ var Fs = require("fs"); +Fs.move = require('fs-extra').move; +Fs.moveSync = require('fs-extra').moveSync; var Path = require("path"); var Https = require("https"); const Package = require('./package.json'); @@ -1054,7 +1056,7 @@ var upload_complete = function (Env, publicKey, id, cb) { } // lol wut handle ur errors - Fs.rename(oldPath, newPath, function (e) { + Fs.move(oldPath, newPath, function (e) { if (e) { WARN('rename', e); return void cb('RENAME_ERR'); @@ -1146,7 +1148,7 @@ var owned_upload_complete = function (Env, safeKey, cb) { // flow is dumb and I need to guard against this which will never happen // / *:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } * / - Fs.rename(oldPath, finalPath, w(function (e) { + Fs.move(oldPath, finalPath, w(function (e) { if (e) { w.abort(); return void cb(e.code); @@ -1254,7 +1256,7 @@ var owned_upload_complete = function (Env, safeKey, id, cb) { // flow is dumb and I need to guard against this which will never happen /*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */ - Fs.rename(oldPath, finalPath, w(function (e) { + Fs.move(oldPath, finalPath, w(function (e) { if (e) { // Remove the ownership file Fs.unlink(finalOwnPath, function (e) { From e2600e4b3694d542470635ffac74fd9093f6566b Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 18 Jul 2018 15:53:12 +0200 Subject: [PATCH 2/6] display a loading screen while users are changing their passwords --- customize.dist/translations/messages.js | 1 + www/settings/inner.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index b16e6d876..ac3ba63fd 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -614,6 +614,7 @@ define(function () { out.settings_changePasswordNewConfirm = "Confirm new password"; out.settings_changePasswordConfirm = "Are you sure you want to change your password? You will need to log back in on all your devices."; out.settings_changePasswordError = "An unexpected error occurred. If you are unable to login or change your password, contact your CryptPad administrators."; + out.settings_changePasswordPending = "Your password is being updated. Please do not close or reload this page until the process has completed."; out.upload_title = "File upload"; out.upload_modal_title = "File upload options"; diff --git a/www/settings/inner.js b/www/settings/inner.js index e3abd389b..407ee5fdb 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -431,10 +431,16 @@ define([ UI.confirm(Messages.settings_changePasswordConfirm, function (yes) { if (!yes) { return; } + + UI.addLoadingScreen({ + hideTips: true, + loadingText: Messages.settings_changePasswordPending, + }); updateBlock({ password: oldPassword, newPassword: newPassword }, function (obj) { + UI.removeLoadingScreen(); if (obj && obj.error) { // TODO UI.alert(Messages.settings_changePasswordError); From 58332a9ce31ca55d78d9ae9ff2f97de0e0a1c1dd Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 18 Jul 2018 15:56:13 +0200 Subject: [PATCH 3/6] add french translation for password change loading screen --- customize.dist/translations/messages.fr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 5325a53e2..851d3648b 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -605,6 +605,7 @@ define(function () { out.settings_changePasswordNewConfirm = "Confirmer le nouveau mot de passe"; out.settings_changePasswordConfirm = "Êtes-vous sûr de vouloir changer votre mot de passe ? Vous devrez vous reconnecter sur tous vos appareils."; out.settings_changePasswordError = "Une erreur est survenue. Si vous n'êtes plus en mesure de vous connecter à votre compte utilisateur ou de changer votre mot de passe, veuillez contacter l'administrateur de votre CryptPad."; + out.settings_changePasswordPending = "Votre mot de passe est en train d'être modifié. Veuillez ne pas fermer ou recharger cette page avant que le traitement soit terminé."; out.upload_title = "Hébergement de fichiers"; out.upload_modal_title = "Options d'importation du fichier"; From 5527949c70716fb541e10589d378c098018e6e49 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Wed, 18 Jul 2018 16:22:44 +0200 Subject: [PATCH 4/6] Make LessLoader flow properly, sorry about that --- www/common/LessLoader.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/www/common/LessLoader.js b/www/common/LessLoader.js index a6942ac77..d9e7d3078 100644 --- a/www/common/LessLoader.js +++ b/www/common/LessLoader.js @@ -8,7 +8,7 @@ define([ '/bower_components/nthen/index.js' ], function (Config, nThen) { /*::});module.exports = (function() { const Config = (undefined:any); - const nThen = require('/bower_components/nthen/index.js'); + const nThen = (undefined:any); */ var module = { exports: {} }; @@ -141,17 +141,16 @@ define([ var loadSubmodulesAndInject = function (css, url, cb, stack) { inject(css, url); - var nt = nThen; - nt = nt(function (w) { + nThen(function (w) { css.replace(/\-\-LessLoader_require\:\s*"([^"]*)"\s*;/g, function (all, u) { u = u.replace(/\?.*$/, ''); module.exports.load(u, w(), stack); + return ''; }); - }).nThen; - nt(function () { cb(); }); + }).nThen(function () { cb(); }); }; - module.exports.load = function (url /*:string*/, cb /*:()=>void*/, stack /*:?Array*/) { + module.exports.load = function (url /*:string*/, cb /*:()=>void*/, stack /*:?Array*/) { var btime = stack ? null : +new Date(); stack = stack || []; if (stack.indexOf(url) > -1) { return void cb(); } From a090dc52db769c5766ba3322f24c3e6727e1390b Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 19 Jul 2018 10:33:01 +0200 Subject: [PATCH 5/6] flow compliance --- package.json | 2 +- rpc.js | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index e4bfa80fd..c685c8efe 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dependencies": { "chainpad-server": "~2.1.0", "express": "~4.16.0", - "mkdirp": "^0.5.1", + "fs-extra": "^7.0.0", "nthen": "~0.1.0", "pull-stream": "^3.6.1", "replify": "^1.2.0", diff --git a/rpc.js b/rpc.js index b13d1c9ad..18cafc65d 100644 --- a/rpc.js +++ b/rpc.js @@ -7,15 +7,14 @@ var Nacl = require("tweetnacl"); /* globals process */ var Fs = require("fs"); -Fs.move = require('fs-extra').move; -Fs.moveSync = require('fs-extra').moveSync; + +var Fse = require("fs-extra"); var Path = require("path"); var Https = require("https"); const Package = require('./package.json'); const Pinned = require('./pinned'); const Saferphore = require("saferphore"); const nThen = require("nthen"); -const Mkdirp = require("mkdirp"); var RPC = module.exports; @@ -1056,7 +1055,7 @@ var upload_complete = function (Env, publicKey, id, cb) { } // lol wut handle ur errors - Fs.move(oldPath, newPath, function (e) { + Fse.move(oldPath, newPath, function (e) { if (e) { WARN('rename', e); return void cb('RENAME_ERR'); @@ -1220,13 +1219,13 @@ var owned_upload_complete = function (Env, safeKey, id, cb) { var finalOwnPath; nThen(function (w) { // make the requisite directory structure using Mkdirp - Mkdirp(filePath, w(function (e /*, path */) { + Fse.mkdirp(filePath, w(function (e /*, path */) { if (e) { // does not throw error if the directory already existed w.abort(); return void cb(e.code); } })); - Mkdirp(ownPath, w(function (e /*, path */) { + Fse.mkdirp(ownPath, w(function (e /*, path */) { if (e) { // does not throw error if the directory already existed w.abort(); return void cb(e.code); @@ -1256,7 +1255,7 @@ var owned_upload_complete = function (Env, safeKey, id, cb) { // flow is dumb and I need to guard against this which will never happen /*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */ - Fs.move(oldPath, finalPath, w(function (e) { + Fse.move(oldPath, finalPath, w(function (e) { if (e) { // Remove the ownership file Fs.unlink(finalOwnPath, function (e) { From 6922bc1e085dd058562a27a91607e6ad8c26ea29 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 19 Jul 2018 11:14:52 +0200 Subject: [PATCH 6/6] lint compliance --- rpc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc.js b/rpc.js index bc7f0e35a..f64fddd48 100644 --- a/rpc.js +++ b/rpc.js @@ -1399,7 +1399,7 @@ var writeLoginBlock = function (Env, msg, cb) { nThen(function (w) { // make sure the path to the file exists - Mkdirp(parsed.dir, w(function (e) { + Fse.mkdirp(parsed.dir, w(function (e) { if (e) { w.abort(); cb(e);