Skip to content

Commit

Permalink
Improved logout on client side
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziga committed May 21, 2021
1 parent ff96b30 commit 5dd535a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions html/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<a href="#" class="border-indigo-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Import & Export
</a>
<a href="login.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
<a href="javascript:logout()" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Sign out
</a>
</div>
Expand All @@ -47,7 +47,7 @@
<div id="mobile-menu" class="hidden pt-2 pb-3 space-y-1">
<a href="passwords.html" class="border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Passwords</a>
<a href="#" class="bg-indigo-50 border-indigo-500 text-indigo-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Import & Export</a>
<a href="login.html" class="border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Sign out</a>
<a href="javascript:logout()" class="border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Sign out</a>
</div>
</div>
</nav>
Expand Down
4 changes: 2 additions & 2 deletions html/passwords.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<a href="export.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Import & Export
</a>
<a href="login.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
<a href="javascript:logout()" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Sign out
</a>
</div>
Expand Down Expand Up @@ -56,7 +56,7 @@
<div id="mobile-menu" class="hidden pt-2 pb-3 space-y-1">
<a href="#" class="bg-indigo-50 border-indigo-500 text-indigo-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Passwords</a>
<a href="export.html" class="border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Import & Export</a>
<a href="login.html" class="border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Sign out</a>
<a href="javascript:logout()" class="border-transparent text-gray-600 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-800 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Sign out</a>
</div>
</div>
</nav>
Expand Down
7 changes: 7 additions & 0 deletions js/default-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,11 @@ function getDate(date) {
let local = new Date(date);
local.setMinutes(date.getMinutes() - date.getTimezoneOffset());
return local.toJSON().slice(0, 10);
}

function logout(){
sessionStorage.url = null;
sessionStorage.username = null;
sessionStorage.password = null;
window.location.href = 'login.html';
}
4 changes: 4 additions & 0 deletions js/export.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(sessionStorage.url == null && typeof(sessionStorage.url) == 'undefined') window.location.href = 'login.html';
if(sessionStorage.username == null && typeof(sessionStorage.username) == 'undefined') window.location.href = 'login.html';
if(sessionStorage.password == null && typeof(sessionStorage.password) == 'undefined') window.location.href = 'login.html';

function backup_passky(){

if(sessionStorage.passwords == null || typeof(sessionStorage.passwords) == 'undefined'){
Expand Down
4 changes: 4 additions & 0 deletions js/prepasswords.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(sessionStorage.url == null && typeof(sessionStorage.url) == 'undefined') window.location.href = 'login.html';
if(sessionStorage.username == null && typeof(sessionStorage.username) == 'undefined') window.location.href = 'login.html';
if(sessionStorage.password == null && typeof(sessionStorage.password) == 'undefined') window.location.href = 'login.html';

function displayPassword(id, website, username, password){
const decrypted_password = CryptoJS.AES.decrypt(password, sessionStorage.password).toString(CryptoJS.enc.Utf8);
const data = id + " " + website + " " + username + " " + decrypted_password;
Expand Down

0 comments on commit 5dd535a

Please sign in to comment.