Added improved messaging
diff --git a/css/main.css b/css/main.css
index e4c698d..e668a86 100644
--- a/css/main.css
+++ b/css/main.css
@@ -1,5 +1,5 @@
-p {
- font-size: 16px;
+body {
+ font-size: 18px;
}
table td {
diff --git a/index.php b/index.php
index 16378a9..f62abd9 100644
--- a/index.php
+++ b/index.php
@@ -9,6 +9,10 @@
<link rel="stylesheet" href="./css/login.css" />
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
+ <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
+
+ <script src="./js/utils.js"></script>
+ <script src="./js/animations.js"></script>
</head>
<body>
<div id="outter-container">
@@ -42,6 +46,13 @@
let nopassword = $('select option:selected').hasClass('nopassword');
$('#password').prop('disabled', nopassword);
});
+
+ $(document).ready(function() {
+ // Notify of messages
+ if (getUrlParameter("passwordchanged")) read_message("La teva clau d'accés ha canviat", "error");
+ if (getUrlParameter("wrongpassword")) read_message("La clau d'accés no és correcta", "error");
+
+ });
</script>
</body>
</html>
diff --git a/js/animations.js b/js/animations.js
index fb04a9a..5eb5e14 100644
--- a/js/animations.js
+++ b/js/animations.js
@@ -4,3 +4,9 @@
$(".victima").fadeIn(400);
});
}
+
+function read_message(msg, type) {
+ $.notify(msg, type);
+ newURL = window.location.href.split('?')[0];
+ history.pushState({}, null, newURL);
+}
diff --git a/main.php b/main.php
index 54212b1..63836b2 100644
--- a/main.php
+++ b/main.php
@@ -59,11 +59,11 @@
<h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2>
<div class="formulari_contrasenya" style="display: none;">
- <p>Sembla que no tens contrasenya, la gent podrà entrar a la teva compta...</p>
+ <p>Sembla que no tens clau d'accés, la gent podrà entrar a la teva compta...</p>
<form action="./php/change_password.php" method="POST">
<input type="hidden" value="<?=$_COOKIE['user']?>" name="userid">
- <input type="password" placeholder="Nova contrasenya..." name="password" /><br />
- <input type="password" placeholder="Repeteix la contrasenya" name="confirmation"/><br />
+ <input type="password" placeholder="Nova clau d'accés..." name="password" /><br />
+ <input type="password" placeholder="Repeteix la clau d'accés" name="confirmation"/><br />
<input type="submit">
</form>
</div>
@@ -92,7 +92,15 @@
// Set interval of checking
let checking = setInterval(function() { update_info(user); }, 1500);
// Set to hidden or not the password prompt
- if (<?=$user->md5password=="" ? 1 : 0?>) $(".formulari_contrasenya").show();
+ if (<?=$user->md5password=="" ? 1 : 0?>) {
+ $.notify("No tens clau d'accés", "info");
+ $(".formulari_contrasenya").show();
+ }
+
+ // Notify of messages
+ if (getUrlParameter("wrongconfirmation")) read_message("Les contrasenyes no coincideixen", "error");
+ if (getUrlParameter("errordb")) read_message("Hi ha hagut un problema a la base de dades, torna-ho a intentar", "error");
+ if (getUrlParameter("successpassword")) read_message("La teva clau d'accés s'ha guardat", "success");
});
</script>
</body>
diff --git a/php/change_password.php b/php/change_password.php
index 82ffcde..6f13127 100644
--- a/php/change_password.php
+++ b/php/change_password.php
@@ -4,7 +4,7 @@
// Check if confirmation is the same
if ($_POST['password'] != $_POST['confirmation']) {
- header("Location: ../main.php?wrong_password=1");
+ header("Location: ../main.php?wrongconfirmation=1");
die();
} else {
// Execute query to change password
diff --git a/php/login.php b/php/login.php
index 4219e2c..9fcdc39 100644
--- a/php/login.php
+++ b/php/login.php
@@ -22,13 +22,17 @@
// Redirect if wrong
if ($real_password != "" && $real_password != md5($password)) {
+ // Forget cookies
+ setcookie('user', '', -1, "/");
+ setcookie('password', '', -1, "/");
+
header("Location: ../index.php?wrongpassword=1");
die();
}
// Save variables as cookies
setcookie('user', $user, time() + (86400 * 10), "/");
- if ($real_password != "") setcookie('password', $password, time() + (86400 * 10), "/");
+ if ($real_password != "") setcookie('password', md5($password), time() + (86400 * 10), "/");
else setcookie('password', '', -1, "/");
// Success, proceed to main page