summaryrefslogtreecommitdiffstats
path: root/static/functions/password_validate.js
diff options
context:
space:
mode:
authorGit <git@what.cd>2015-08-22 08:00:28 +0000
committerGit <git@what.cd>2015-08-22 08:00:28 +0000
commitf668501ef0e34082f941a6bf9b72e0986a00f4c6 (patch)
treecd3db9c98cff1783aded1abc9c6c799b7d1b8da5 /static/functions/password_validate.js
parentabbd28e076a0b811847a0a312cba9b4fb6c7d846 (diff)
downloadGazelle-f668501ef0e34082f941a6bf9b72e0986a00f4c6.zip
Gazelle-f668501ef0e34082f941a6bf9b72e0986a00f4c6.tar.gz
Gazelle-f668501ef0e34082f941a6bf9b72e0986a00f4c6.tar.bz2
Empty commit
Diffstat (limited to 'static/functions/password_validate.js')
-rw-r--r--static/functions/password_validate.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/static/functions/password_validate.js b/static/functions/password_validate.js
index e6cb4f8..df1a58d 100644
--- a/static/functions/password_validate.js
+++ b/static/functions/password_validate.js
@@ -11,6 +11,7 @@ var SHORT = 4;
var MATCH_IRCKEY = 5;
var MATCH_USERNAME = 6;
var COMMON = 7;
+var MATCH_OLD_PASSWORD = 8;
var USER_PATH = "/user.php";
@@ -85,6 +86,7 @@ function validatePassword(password) {
function calculateComplexity(password) {
var length = password.length;
var username;
+ var oldPassword;
if (isUserPage()) {
username = $(".username").text();
@@ -97,12 +99,13 @@ function calculateComplexity(password) {
if (isUserPage()) {
irckey = $("#irckey").val();
+ oldPassword =$("#cur_pass").val();
}
- if (length >= 8) {
+ if (length >= 8 && length < 20) {
setStatus(WEAK);
}
- if (length >= 8 && isStrongPassword(password)) {
+ if ((length >= 8 && isStrongPassword(password)) || length >= 20) {
setStatus(STRONG);
}
if (length > 0 && length < 8) {
@@ -117,6 +120,10 @@ function calculateComplexity(password) {
setStatus(MATCH_IRCKEY);
}
}
+
+ if (oldPassword.length > 0 && password == oldPassword) {
+ setStatus(MATCH_OLD_PASSWORD);
+ }
}
if (username.length > 0) {
if (password.toLowerCase() == username.toLowerCase()) {
@@ -175,6 +182,10 @@ function setStatus(strength) {
disableSubmit();
$("#pass_strength").text("Password is too common").css("color", "red");
}
+ if (strength == MATCH_OLD_PASSWORD) {
+ disableSubmit();
+ $("#pass_strength").text("New password cannot match old password").css("color", "red");
+ }
if (strength == CLEAR) {
$("#pass_strength").text("");
}