latest work

pull/1/head
ansuz 8 years ago
parent 1f762ce55b
commit 3197b62fbb

@ -4,6 +4,7 @@
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script data-main="main" src="/bower_components/requirejs/require.js"></script> <script data-main="main" src="/bower_components/requirejs/require.js"></script>
<link rel="stylesheet" href="/customize/main.css" />
<style> <style>
html, body{ html, body{
padding: 0px; padding: 0px;
@ -16,12 +17,16 @@
width: 80vw; width: 80vw;
min-width: 1000px; min-width: 1000px;
margin: auto; margin: auto;
padding-top: 50px;
} }
div.box, div.logout { div#login-box, div#logout-box {
width: 50%; width: 50%;
margin: auto;
border: 1px solid black; border: 1px solid black;
padding: 15px; padding: 15px;
display: none; display: none;
background-color: #333;
border-radius: 5px;
} }
input[type="text"], input[type="password"] { input[type="text"], input[type="password"] {
width: 80%; width: 80%;
@ -32,13 +37,11 @@
</head> </head>
<body> <body>
<div id="login-box">
<div class="box">
<div id="warning" data-localization="login_warning"></div> <div id="warning" data-localization="login_warning"></div>
<input type="text" name="username" id="username" data-localization-placeholder="login_username" autofocus><br /> <input type="text" name="username" id="username" data-localization-placeholder="login_username" autofocus><br />
<input type="password" name="password" id="password" data-localization-placeholder="login_password"><br /> <input type="password" name="password" id="password" data-localization-placeholder="login_password"><br />
<label for="register" data-localization="login_register"></label> <label for="register" data-localization="login_register"></label>
<input type="checkbox" name="register" id="register"><br /> <input type="checkbox" name="register" id="register"><br />
<input type="password" name="confirm" id="confirm" data-localization-placeholder="login_confirm"> <input type="password" name="confirm" id="confirm" data-localization-placeholder="login_confirm">
@ -47,8 +50,10 @@
<button id="login" data-localization="login_login"></button> <button id="login" data-localization="login_login"></button>
<input type="checkbox" name="remember" id="remember"><label for="remember" data-localization="login_remember"></label> <input type="checkbox" name="remember" id="remember"><label for="remember" data-localization="login_remember"></label>
</div> </div>
<div class="logout">
<div id="logout-box">
<div data-localization="login_logout"></div> <div data-localization="login_logout"></div>
<button id="logout">logout</button> <button id="logout">logout</button>
</div> </div>

@ -12,8 +12,6 @@ define([
var Scrypt = window.scrypt; var Scrypt = window.scrypt;
var Nacl = window.nacl; var Nacl = window.nacl;
Cryptpad.styleAlerts();
var secret = {}; var secret = {};
var APP = window.APP = { var APP = window.APP = {
@ -21,6 +19,27 @@ define([
Crypto: Crypto, Crypto: Crypto,
}; };
var $warning = $('#warning');
var $login = $('#login');
var $logout = $('#logout');
var $username = $('#username');
var $password = $('#password');
var $confirm = $('#confirm');
var $remember = $('#remember');
var $loginBox = $('#login-box');
var $logoutBox = $('#logout-box');
var revealLogin = function () {
$loginBox.slideDown();
};
var $logout = $logout.click(function () {
Cryptpad.logout(function () {
$logoutBox.slideUp();
revealLogin();
});
});
var hashFromCreds = function (username, password, len, cb) { var hashFromCreds = function (username, password, len, cb) {
Scrypt(password, Scrypt(password,
username, username,
@ -82,6 +101,7 @@ define([
// 32 more for a signing key // 32 more for a signing key
var edSeed = consume(32); var edSeed = consume(32);
var seed = {}; var seed = {};
var keys = seed.keys = Crypto.createEditCryptor(null, encryptionSeed); var keys = seed.keys = Crypto.createEditCryptor(null, encryptionSeed);
@ -124,9 +144,26 @@ define([
/* if the user is registering, we expect that the userDoc will be empty /* if the user is registering, we expect that the userDoc will be empty
*/ */
var proxyKeys = Object.keys(proxy);
if (opt.register) { if (opt.register) {
if (Object.keys(proxy).length) { if (proxyKeys.length) {
// user is trying to register, but the userDoc is not empty
// tell them they are already registered.
alreadyExists(); alreadyExists();
} else {
// trying to register, and the object is empty, as expected
}
} else {
if (proxyKeys.length) {
// user has already initialized the object, as expected
} else {
// user has logged in, but there is no object here
// they should confirm their password
// basically this means registering
} }
} }
@ -146,7 +183,9 @@ define([
console.log("remembering your userhash"); console.log("remembering your userhash");
Cryptpad.login(userHash, opt.remember); Cryptpad.login(userHash, opt.remember);
//console.log(userHash); console.log(userHash);
$('div#login-box').slideUp();
$('div#logout-box').slideDown();
//console.log(proxy); //console.log(proxy);
}) })
.on('disconnect', function (info) { .on('disconnect', function (info) {
@ -154,27 +193,6 @@ define([
console.log(info); console.log(info);
}); });
}; };
var $warning = $('#warning');
var $login = $('#login');
var $username = $('#username');
var $password = $('#password');
var $confirm = $('#confirm');
var $remember = $('#remember');
var revealLogin = function () {
$('.box').slideDown();
};
var $logoutBox = $('div.logout');
var $logout = $('#logout').click(function () {
Cryptpad.logout(function () {
// noop?
$logout.slideUp();
revealLogin();
});
});
var $register = $('#register').click(function () { var $register = $('#register').click(function () {
if (!$register.length) { return; } if (!$register.length) { return; }
var e = $register[0]; var e = $register[0];
@ -196,11 +214,13 @@ define([
$register[0].checked = false; $register[0].checked = false;
}; };
Cryptpad.ready(function () {
if (Cryptpad.getUserHash()) { if (Cryptpad.getUserHash()) {
//Cryptpad.alert("You are already logged in!"); //Cryptpad.alert("You are already logged in!");
$logoutBox.slideDown(); $logoutBox.slideDown();
} else { } else {
revealLogin(); revealLogin();
//$logoutBox.hide();
} }
$login.click(function () { $login.click(function () {
@ -232,4 +252,5 @@ define([
}); });
}); });
}); });
});
}); });

Loading…
Cancel
Save