-
+
-
+
+
+
+
+
+
diff --git a/customize.dist/main.css b/customize.dist/main.css
index 4c4ac11c7..5c8d6ae96 100644
--- a/customize.dist/main.css
+++ b/customize.dist/main.css
@@ -672,9 +672,6 @@ html.cp,
background-color: #000;
opacity: 0.3;
}
-.cp #mainBlock.hidden {
- display: none;
-}
.cp #noscriptContainer {
color: black;
position: absolute;
@@ -709,6 +706,9 @@ html.cp,
background-attachment: fixed;
background-position: center;
}
+.cp #main .hidden {
+ display: none !important;
+}
.cp #main_other {
padding: 0 15vw;
}
@@ -777,6 +777,32 @@ html.cp,
margin-top: 20px;
margin-bottom: 5px;
}
+.cp #main #loggedIn,
+.cp #main_other #loggedIn {
+ color: #fff;
+ display: inline-block;
+ position: absolute;
+ top: 50%;
+ right: 0;
+ margin-left: 50px;
+ width: 350px;
+ max-width: 35%;
+ transform: translateY(-50%);
+ text-align: center;
+ font-weight: bold;
+}
+.cp #main #loggedIn button,
+.cp #main_other #loggedIn button {
+ font-weight: bold;
+ cursor: pointer;
+}
+.cp #main #loggedIn p,
+.cp #main_other #loggedIn p {
+ margin: 20px;
+ padding: 0;
+ font-size: 20px;
+ line-height: 1.5em;
+}
.cp #main #userForm,
.cp #main_other #userForm {
position: absolute;
diff --git a/customize.dist/main.js b/customize.dist/main.js
index 5606b1960..e05096074 100644
--- a/customize.dist/main.js
+++ b/customize.dist/main.js
@@ -6,32 +6,49 @@ define([
'/customize/languageSelector.js',
'/bower_components/jquery/dist/jquery.min.js',
], function (Messages, Config, Cryptpad, LilUri, LS) {
- if (Cryptpad.isLoggedIn()) {
- document.location.href = '/drive';
- return;
- }
-
var $ = window.$;
-
- var USE_TABLE = Config.USE_HOMEPAGE_TABLE;
- var USE_FS_STORE = Config.USE_FS_STORE;
+ var $main = $('#mainBlock');
var APP = window.APP = {
Cryptpad: Cryptpad,
};
+ // Language selector
+ var $sel = $('#language-selector');
+ Cryptpad.createLanguageSelector(undefined, $sel);
+ $sel.find('button').addClass('btn').addClass('btn-secondary');
+ $sel.show();
+
+ $(window).click(function () {
+ $('.cryptpad-dropdown').hide();
+ });
+
// main block is hidden in case javascript is disabled
- $('#mainBlock').removeClass('hidden');
+ $main.removeClass('hidden');
- var padTypes = {
- '/pad/': Messages.type.pad,
- '/code/': Messages.type.code,
- '/poll/': Messages.type.poll,
- '/slide/': Messages.type.slide,
- };
+ // Make sure we don't display non-translated content (empty button)
+ $main.find('#data').removeClass('hidden');
+
+ if (Cryptpad.isLoggedIn()) {
+ var name = localStorage[Cryptpad.userNameKey] || sessionStorage[Cryptpad.userNameKey];
+ var $loggedInBlock = $main.find('#loggedIn');
+ var $hello = $loggedInBlock.find('#loggedInHello');
+ var $logout = $loggedInBlock.find('#loggedInLogOut');
- var now = new Date();
- var hasRecent = false;
+ $hello.text(Messages._getKey('login_hello', [name]));
+ $('#buttons').find('.nologin').hide();
+
+ $logout.click(function () {
+ Cryptpad.logout(function () {
+ window.location.reload();
+ });
+ });
+
+ $loggedInBlock.removeClass('hidden');
+ //return;
+ } else {
+ $main.find('#userForm').removeClass('hidden');
+ }
var displayCreateButtons = function () {
var $parent = $('#buttons');
@@ -55,17 +72,6 @@ define([
$block.find('button').addClass('btn').addClass('btn-success');
$block.appendTo($parent);
};
-
- // Language selector
- var $sel = $('#language-selector');
- Cryptpad.createLanguageSelector(undefined, $sel);
- $sel.find('button').addClass('btn').addClass('btn-secondary');
- $sel.show();
-
- $(window).click(function () {
- $sel.find('.cryptpad-dropdown').hide();
- });
-
var addButtonHandlers = function () {
$('button.login').click(function (e) {
var username = $('#name').val();
diff --git a/customize.dist/src/fragments/index.html b/customize.dist/src/fragments/index.html
index 66f474156..914194cde 100644
--- a/customize.dist/src/fragments/index.html
+++ b/customize.dist/src/fragments/index.html
@@ -3,14 +3,14 @@
-
+
-
+
+
+
+
+
+
diff --git a/customize.dist/src/less/cryptpad.less b/customize.dist/src/less/cryptpad.less
index 6a9e52190..29b263b3c 100644
--- a/customize.dist/src/less/cryptpad.less
+++ b/customize.dist/src/less/cryptpad.less
@@ -239,11 +239,6 @@ body.html {
background-color: #000;
opacity: 0.3;
}
-#mainBlock {
- &.hidden {
- display: none;
- }
-}
#noscriptContainer {
color: black;
position: absolute;
@@ -277,6 +272,9 @@ body.html {
background-size: cover;
background-attachment: fixed;
background-position: center;
+ .hidden {
+ display: none !important;
+ }
}
#main_other {
padding: 0 @main-border-width;
@@ -344,6 +342,31 @@ body.html {
}
}
+ #loggedIn {
+ color: @main-color;
+ display: inline-block;
+ position: absolute;
+ top: 50%;
+ right: 0;
+ margin-left: 50px;
+ width: 350px;
+ max-width: 35%;
+ transform: translateY(-50%);
+ text-align: center;
+ font-weight: bold;
+ button {
+ font-weight: bold;
+ cursor: pointer;
+ }
+ p {
+ margin: 20px;
+ padding: 0;
+ font-size: 20px;
+ line-height: 1.5em;
+ }
+
+ }
+
#userForm {
position: absolute;
right: 0;
diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index cb88b4987..da7f341da 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -278,6 +278,8 @@ define(function () {
out.loginText = '
Votre nom d\'utilisateur et votre mot d epasse sont utilisés pour générer une clé unique qui reste inconnue de notre serveur.
\n' + 'Faîtes attention de ne pas perdre vos identifiants, puisqu\'il est impossible de les récupérer
'; + out.login_hello = 'Bonjour {0},'; // {0} is the username + out.login_accessDrive = 'Accédez à votre drive'; // index.html diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 95257b256..7a760c364 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -280,6 +280,8 @@ define(function () { out.loginText = 'Your username and password are used to generate a unique key which is never known by our server.
\n' + 'Be careful not to forget your credentials, as they are impossible to recover
'; + out.login_hello = 'Hello {0},'; // {0} is the username + out.login_accessDrive = 'Access your drive'; // index.html diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 1f11e2783..a7bbf746b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -65,22 +65,26 @@ define([ }; var userHashKey = common.userHashKey = 'User_hash'; + var userNameKey = common.userNameKey = 'User_name'; var fileHashKey = common.fileHashKey = 'FS_hash'; - var login = common.login = function (hash, remember, cb) { + var login = common.login = function (hash, name, remember, cb) { if (!hash) { throw new Error('expected a user hash'); } + if (!name) { throw new Error('expected a user name'); } if (!remember) { sessionStorage.setItem(userHashKey, hash); + sessionStorage.setItem(userNameKey, name); } else { localStorage.setItem(userHashKey, hash); + localStorage.setItem(userNameKey, name); } if (cb) { cb(); } }; var logout = common.logout = function (cb) { [ -// fileHashKey, + userNameKey, userHashKey, ].forEach(function (k) { sessionStorage.removeItem(k); diff --git a/www/user/main.js b/www/user/main.js index 414691ad3..c1da83fe2 100644 --- a/www/user/main.js +++ b/www/user/main.js @@ -131,7 +131,7 @@ define([ APP.setAccountName(getAccountName(proxy)); APP.setDisplayName(getDisplayName(proxy)); - Cryptpad.login(opt.userHash, opt.remember); + Cryptpad.login(opt.userHash, getAccountName(proxy), opt.remember); APP.revealLogin(false); APP.revealUser(true); APP.revealLogout(true);