|
|
|
@ -34,6 +34,10 @@ define([
|
|
|
|
|
$notice.text(s);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
APP.redirectToDrive = function () {
|
|
|
|
|
document.location.href = '/drive/';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// confirm elements
|
|
|
|
|
var $confirmBox = $('#confirm-panel');
|
|
|
|
|
var $confirm = $('#confirm');
|
|
|
|
@ -60,13 +64,7 @@ define([
|
|
|
|
|
var revealConfirm = APP.revealConfirm = revealer($confirmBox);
|
|
|
|
|
|
|
|
|
|
var revealLogout = APP.revealLogout= revealer($logoutBox);
|
|
|
|
|
var revealUser_false = APP.revealUser_false = revealer($userBox);
|
|
|
|
|
var revealUser = APP.revealUser = function (state) {
|
|
|
|
|
if (!state) {
|
|
|
|
|
revealUser_false(state);
|
|
|
|
|
}
|
|
|
|
|
document.location.href = '/drive';
|
|
|
|
|
};
|
|
|
|
|
var revealUser = APP.revealUser = revealer($userBox);
|
|
|
|
|
|
|
|
|
|
var getDisplayName = APP.getDisplayName = function (proxy) {
|
|
|
|
|
return proxy['cryptpad.username'];
|
|
|
|
@ -105,7 +103,7 @@ define([
|
|
|
|
|
revealLogin(true);
|
|
|
|
|
revealUser(false);
|
|
|
|
|
APP.abort();
|
|
|
|
|
$username.focus();
|
|
|
|
|
//$username.focus();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
@ -128,10 +126,9 @@ define([
|
|
|
|
|
APP.setAccountName(getAccountName(proxy));
|
|
|
|
|
APP.setDisplayName(getDisplayName(proxy));
|
|
|
|
|
|
|
|
|
|
Cryptpad.login(opt.userHash, getAccountName(proxy), opt.remember);
|
|
|
|
|
Cryptpad.login(opt.userHash, getAccountName(proxy));
|
|
|
|
|
APP.revealLogin(false);
|
|
|
|
|
APP.revealUser(true);
|
|
|
|
|
APP.revealLogout(true);
|
|
|
|
|
APP.redirectToDrive();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var abortRegistration = function () {
|
|
|
|
@ -164,8 +161,8 @@ define([
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
addEnterListener($confirm, function () {
|
|
|
|
|
$register.click();
|
|
|
|
|
addEnterListener($password_register, function () {
|
|
|
|
|
$login.click();
|
|
|
|
|
});
|
|
|
|
|
addEnterListener($password, function () {
|
|
|
|
|
$login.click();
|
|
|
|
@ -318,33 +315,30 @@ define([
|
|
|
|
|
console.log(info);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
Cryptpad.ready(function () {
|
|
|
|
|
if (Cryptpad.getUserHash()) {
|
|
|
|
|
|
|
|
|
|
var showUserInfo = function () {
|
|
|
|
|
/* TODO use something like this for a user preferences page
|
|
|
|
|
|
|
|
|
|
revealLogout(true);
|
|
|
|
|
var proxy = Cryptpad.getStore().getProxy().proxy;
|
|
|
|
|
|
|
|
|
|
APP.setAccountName(proxy.login_name);
|
|
|
|
|
APP.setDisplayName(getDisplayName(proxy));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
revealUser(true);
|
|
|
|
|
} else {
|
|
|
|
|
if (sessionStorage.register || document.location.hash.slice(1) === 'register') {
|
|
|
|
|
document.location.hash = 'register';
|
|
|
|
|
$login.text(Cryptpad.Messages.login_register);
|
|
|
|
|
$('#login-panel .register').show();
|
|
|
|
|
}
|
|
|
|
|
revealLogin(true);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$username.focus();
|
|
|
|
|
Cryptpad.ready(function () {
|
|
|
|
|
// If the user is already logged in...
|
|
|
|
|
// TODO show user preferences
|
|
|
|
|
if (Cryptpad.getUserHash()) { return APP.redirectToDrive(); }
|
|
|
|
|
|
|
|
|
|
$login.click(function () {
|
|
|
|
|
var uname = $username.val().trim();
|
|
|
|
|
var passwd = $password.val();
|
|
|
|
|
var passwd_confirm = $password_register.val();
|
|
|
|
|
var confirm = $confirm.val();
|
|
|
|
|
var remember = $remember[0].checked;
|
|
|
|
|
remember = true; // TODO : find a way to use a sessionStorage shared with all tabs
|
|
|
|
|
|
|
|
|
|
var register = document.location.hash.slice(1) === 'register';
|
|
|
|
|
|
|
|
|
@ -362,39 +356,50 @@ define([
|
|
|
|
|
|
|
|
|
|
revealNotice(true);
|
|
|
|
|
revealLogin(false, function () {
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
resetUI();
|
|
|
|
|
// dispense 128 bytes, to be divided later
|
|
|
|
|
// we can safely increase this size, but we don't need much right now
|
|
|
|
|
Cred.deriveFromPassphrase(uname, passwd, 128, function (bytes) {
|
|
|
|
|
revealNotice(false);
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
useBytes(bytes, {
|
|
|
|
|
remember: remember,
|
|
|
|
|
register: register,
|
|
|
|
|
name: uname,
|
|
|
|
|
password: passwd,
|
|
|
|
|
});
|
|
|
|
|
}, 75);
|
|
|
|
|
});
|
|
|
|
|
}, 75);
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
resetUI();
|
|
|
|
|
// dispense 128 bytes, to be divided later
|
|
|
|
|
// we can safely increase this size, but we don't need much right now
|
|
|
|
|
Cred.deriveFromPassphrase(uname, passwd, 128, function (bytes) {
|
|
|
|
|
revealNotice(false);
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
useBytes(bytes, {
|
|
|
|
|
register: register,
|
|
|
|
|
name: uname,
|
|
|
|
|
password: passwd,
|
|
|
|
|
});
|
|
|
|
|
}, 75);
|
|
|
|
|
});
|
|
|
|
|
}, 75);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (sessionStorage.login) {
|
|
|
|
|
$username.val(sessionStorage.login_user);
|
|
|
|
|
$password.val(sessionStorage.login_pass);
|
|
|
|
|
$remember.attr('checked', sessionStorage.login_rmb === "true");
|
|
|
|
|
$login.click();
|
|
|
|
|
// if the user is not logged in...
|
|
|
|
|
if (sessionStorage.register || document.location.hash.slice(1) === 'register') {
|
|
|
|
|
Cryptpad.replaceHash('register');
|
|
|
|
|
$login.text(Cryptpad.Messages.login_register);
|
|
|
|
|
$('#login-panel .register').show();
|
|
|
|
|
}
|
|
|
|
|
if (sessionStorage.register) {
|
|
|
|
|
|
|
|
|
|
$username.focus();
|
|
|
|
|
|
|
|
|
|
if (sessionStorage.login || sessionStorage.register) {
|
|
|
|
|
$username.val(sessionStorage.login_user);
|
|
|
|
|
$password.val(sessionStorage.login_pass);
|
|
|
|
|
$remember.attr('checked', sessionStorage.login_rmb === "true");
|
|
|
|
|
}
|
|
|
|
|
['login', 'register', 'login_user', 'login_pass', 'login_rmb'].forEach(function (k) {
|
|
|
|
|
delete sessionStorage[k];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (sessionStorage.login) {
|
|
|
|
|
APP.setNotice(Cryptpad.Messages.login_hashing);
|
|
|
|
|
APP.revealNotice(true, function () {
|
|
|
|
|
$login.click();
|
|
|
|
|
Cryptpad.eraseTempSessionValues();
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
revealLogin(true, function () {
|
|
|
|
|
if (sessionStorage.register) { $password_register.focus(); }
|
|
|
|
|
Cryptpad.eraseTempSessionValues();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|