Skip to content

Commit 98cedc6

Browse files
added new requirements for password at app_sec
1 parent 479edad commit 98cedc6

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

app/img/example.jpg

100644100755
File mode changed.

app_sec/change-password.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
if ($pwd !== $pwdRepeat) {
3232
header("Location: change-password.php?submit=invalid");
3333
exit();
34+
35+
}else if(strlen($pwd) < 6 || !preg_match('/[A-Z]/', $pwd) || !preg_match('/[\'^£!$%&*()}{@#~?><>,|=_+¬-]/', $pwd)){
36+
header("Location: change-password.php?submit=pwdnotvalid");
37+
exit();
3438
} else {
3539
$sql = "UPDATE users_sec SET pwd=? WHERE username='".$_SESSION["userUsername"]."'";
3640
$stmt = mysqli_stmt_init($conn);
@@ -154,6 +158,16 @@
154158
</div>
155159
";
156160
break;
161+
case "pwdnotvalid":
162+
echo "
163+
<div class=\"alert alert-danger alert-dismissible fade show\">
164+
<i class=\"fas fa-times-circle\"></i> <strong>ERRO:</strong> A palavras-passe introduzida não corresponde aos requisitos mínimos! (pelo menos 8 caracteres, uma letra maiuscula e um símbolo)
165+
<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">
166+
<span aria-hidden=\"true\">×</span>
167+
</button>
168+
</div>
169+
";
170+
break;
157171
}
158172
}
159173
?>

app_sec/img/example.jpg

100644100755
File mode changed.

app_sec/signup.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
if ($pwd !== $pwdRepeat) {
2626
header("Location: signup.php?submit=missmatchpwd&username=".$username."&email=".$email);
2727
exit();
28-
}
28+
}else if(strlen($pwd) < 8 || !preg_match('/[A-Z]/', $pwd) || !preg_match('/[\'^£$%&*()}!{@#~?><>,|=_+¬-]/', $pwd)){
29+
header("Location: signup.php?submit=pwdnotvalid&username=".$username."&email=".$email);
30+
exit();
31+
}
2932
else {
3033
// check if username exists
3134
$sql = "SELECT * FROM users WHERE username=?;";
@@ -172,6 +175,16 @@
172175
</div>
173176
";
174177
break;
178+
case "pwdnotvalid":
179+
echo "
180+
<div class=\"alert alert-danger alert-dismissible fade show\">
181+
<i class=\"fas fa-times-circle\"></i> <strong>ERRO:</strong> A palavras-passe introduzida não corresponde aos requisitos mínimos! (pelo menos 8 caracteres, uma letra maiuscula e um símbolo)
182+
<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">
183+
<span aria-hidden=\"true\">×</span>
184+
</button>
185+
</div>
186+
";
187+
break;
175188
}
176189
}
177190
?>

0 commit comments

Comments
 (0)