Own drive migration
This commit is contained in:
parent
bbc06f668f
commit
f2f9b57505
@ -456,7 +456,8 @@ define([
|
|||||||
edPublic: store.proxy.edPublic,
|
edPublic: store.proxy.edPublic,
|
||||||
friends: store.proxy.friends || {},
|
friends: store.proxy.friends || {},
|
||||||
settings: store.proxy.settings,
|
settings: store.proxy.settings,
|
||||||
thumbnails: disableThumbnails === false
|
thumbnails: disableThumbnails === false,
|
||||||
|
isDriveOwned: Boolean(Util.find(store, ['driveMetadata', 'owners']))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
cb(JSON.parse(JSON.stringify(metadata)));
|
cb(JSON.parse(JSON.stringify(metadata)));
|
||||||
@ -1523,8 +1524,9 @@ define([
|
|||||||
if (!data.userHash) {
|
if (!data.userHash) {
|
||||||
returned.anonHash = Hash.getEditHashFromKeys(secret);
|
returned.anonHash = Hash.getEditHashFromKeys(secret);
|
||||||
}
|
}
|
||||||
}).on('ready', function () {
|
}).on('ready', function (info) {
|
||||||
if (store.userObject) { return; } // the store is already ready, it is a reconnection
|
if (store.userObject) { return; } // the store is already ready, it is a reconnection
|
||||||
|
store.driveMetadata = info.metadata;
|
||||||
if (!rt.proxy.drive || typeof(rt.proxy.drive) !== 'object') { rt.proxy.drive = {}; }
|
if (!rt.proxy.drive || typeof(rt.proxy.drive) !== 'object') { rt.proxy.drive = {}; }
|
||||||
var drive = rt.proxy.drive;
|
var drive = rt.proxy.drive;
|
||||||
// Creating a new anon drive: import anon pads from localStorage
|
// Creating a new anon drive: import anon pads from localStorage
|
||||||
|
|||||||
@ -667,6 +667,7 @@ define(function () {
|
|||||||
out.settings_ownDriveHint = "Migrating your drive to the new version will give you access to new features..."; // XXX
|
out.settings_ownDriveHint = "Migrating your drive to the new version will give you access to new features..."; // XXX
|
||||||
out.settings_ownDriveButton = "Migrate"; // XXX
|
out.settings_ownDriveButton = "Migrate"; // XXX
|
||||||
out.settings_ownDriveConfirm = "Are you sure?"; // XXX
|
out.settings_ownDriveConfirm = "Are you sure?"; // XXX
|
||||||
|
out.settings_ownDrivePending = "Your account is being migrated. Please do not close or reload this page until the process has completed."; // XXX
|
||||||
|
|
||||||
out.settings_changePasswordTitle = "Change your password";
|
out.settings_changePasswordTitle = "Change your password";
|
||||||
out.settings_changePasswordHint = "Change your account's password. Enter your current password, and confirm the new password by typing it twice.<br>" +
|
out.settings_changePasswordHint = "Change your account's password. Enter your current password, and confirm the new password by typing it twice.<br>" +
|
||||||
|
|||||||
@ -154,7 +154,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cp-settings-change-password {
|
.cp-settings-change-password, .cp-settings-migrate {
|
||||||
[type="password"], [type="text"] {
|
[type="password"], [type="text"] {
|
||||||
width: @sidebar_button-width;
|
width: @sidebar_button-width;
|
||||||
flex: unset;
|
flex: unset;
|
||||||
|
|||||||
@ -52,6 +52,7 @@ define([
|
|||||||
'cp-settings-autostore',
|
'cp-settings-autostore',
|
||||||
'cp-settings-userfeedback',
|
'cp-settings-userfeedback',
|
||||||
'cp-settings-change-password',
|
'cp-settings-change-password',
|
||||||
|
'cp-settings-migrate',
|
||||||
'cp-settings-backup',
|
'cp-settings-backup',
|
||||||
'cp-settings-delete'
|
'cp-settings-delete'
|
||||||
],
|
],
|
||||||
@ -473,10 +474,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
create['migrate'] = function () {
|
create['migrate'] = function () {
|
||||||
if (true) { return; } // STUBBED until we have a reason to deploy this
|
if (privateData.isDriveOwned) { return; }
|
||||||
// TODO
|
|
||||||
// if (!loginBlock) { return; }
|
|
||||||
// if (alreadyMigrated) { return; }
|
|
||||||
if (!common.isLoggedIn()) { return; }
|
if (!common.isLoggedIn()) { return; }
|
||||||
|
|
||||||
var $div = $('<div>', { 'class': 'cp-settings-migrate cp-sidebarlayout-element'});
|
var $div = $('<div>', { 'class': 'cp-settings-migrate cp-sidebarlayout-element'});
|
||||||
@ -489,25 +487,49 @@ define([
|
|||||||
var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved});
|
var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved});
|
||||||
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'});
|
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'});
|
||||||
|
|
||||||
var $button = $('<button>', {'id': 'cp-settings-delete', 'class': 'btn btn-primary'})
|
var form = h('div', [
|
||||||
.text(Messages.settings_ownDriveButton).appendTo($div);
|
UI.passwordInput({
|
||||||
|
id: 'cp-settings-migrate-password',
|
||||||
|
placeholder: Messages.settings_changePasswordCurrent
|
||||||
|
}, true),
|
||||||
|
h('button.btn.btn-primary', Messages.settings_ownDriveButton)
|
||||||
|
]);
|
||||||
|
|
||||||
$button.click(function () {
|
$(form).appendTo($div);
|
||||||
|
|
||||||
|
var todo = function () {
|
||||||
|
var password = $(form).find('#cp-settings-migrate-password').val();
|
||||||
|
if (!password) { return; }
|
||||||
$spinner.show();
|
$spinner.show();
|
||||||
UI.confirm(Messages.settings_ownDriveConfirm, function (yes) {
|
UI.confirm(Messages.settings_ownDriveConfirm, function (yes) {
|
||||||
if (!yes) { return; }
|
if (!yes) { return; }
|
||||||
sframeChan.query("Q_OWN_USER_DRIVE", null, function (err, data) {
|
var data = {
|
||||||
if (err || data.error) {
|
password: password,
|
||||||
console.error(err || data.error);
|
newPassword: password
|
||||||
// TODO
|
};
|
||||||
$spinner.hide();
|
UI.addLoadingScreen({
|
||||||
return;
|
hideTips: true,
|
||||||
}
|
loadingText: Messages.settings_ownDrivePending,
|
||||||
// TODO: drive is migrated, autoamtic redirect from outer?
|
});
|
||||||
|
sframeChan.query('Q_CHANGE_USER_PASSWORD', data, function (err, obj) {
|
||||||
|
UI.removeLoadingScreen();
|
||||||
|
if (err || obj.error) { return UI.alert(Messages.settings_changePasswordError); }
|
||||||
$ok.show();
|
$ok.show();
|
||||||
$spinner.hide();
|
$spinner.hide();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$(form).find('button').click(function () {
|
||||||
|
todo();
|
||||||
|
});
|
||||||
|
$(form).find('input').keydown(function (e) {
|
||||||
|
// Save on Enter
|
||||||
|
if (e.which === 13) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
todo();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$spinner.hide().appendTo($div);
|
$spinner.hide().appendTo($div);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user