Skip to content

Commit

Permalink
Merged dev into 108_Change_to_custom_modal #108
Browse files Browse the repository at this point in the history
  • Loading branch information
JayXPan committed May 6, 2023
2 parents c3af93e + 0ab93bd commit fa7d6df
Show file tree
Hide file tree
Showing 14 changed files with 635 additions and 229 deletions.
53 changes: 53 additions & 0 deletions backend/changePassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

include("connection.php");
include("security.php");
access_control();

session_start();


if($_SERVER["REQUEST_METHOD"] == "POST"){

$old_password = htmlspecialchars(trim($_POST["old_password"]), ENT_QUOTES);
$new_password = htmlspecialchars(trim($_POST["new_password"]), ENT_QUOTES);
$user_id = $_SESSION["user_id"];

$query = "SELECT password FROM users WHERE user_id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$hashed_password = $row["password"];
$hashed_new_password = "";

if (password_verify($old_password, $hashed_password)){


if (!contains_char_and_num($new_password)){
$response["status"] = "error";
$response["message"] = "Your new password should be a mix between characters and numbers";
} else if (!is_long_password($new_password)){
$response["status"] = "error";
$response["message"] = "Your new password needs to be at least 8 characters long";
} else {

$hashed_new_password = password_hash($new_password, PASSWORD_DEFAULT);
$query = "UPDATE users SET password = ? WHERE user_id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("si", $hashed_new_password, $user_id);
$stmt->execute();
$response["message"] = "Password updated successfully";
}
} else {
$response["status"] = "error";
$response["message"] = "The current password you entered is incorrect";
}

echo json_encode($response);
}
?>



10 changes: 5 additions & 5 deletions src/NavBar/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ export default {
left: 12.1%;
}
.menu-edit {
top: 1.1%;
left: 55.5%;
height: 55px;
width: 45px;
position: absolute;
top: 13.1%;
left: -105.5%;
}
.profile_image_loggedin{
margin-top: -1%;
height: 40px;
left: 64%;
left: 60%;
transform: scale(0.7)
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/SettingsComponent/SettingsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<li id = "button1" ><a href="#/unitsSettings">Unit Settings</a></li>
<li id = "button2" ><a href="#/locationSettings">Location Settings</a></li>
<li id = "button3" ><a href="#/tempSettings">Temperature Settings</a></li>
<li id = "button4"><a href="#/accountSettings">Account Settings</a></li>
<li id = "button4"> <a href="#/accountSettings">Account Settings</a></li>
</ul>
</div>

Expand Down Expand Up @@ -203,13 +203,13 @@ export default {
user-select: none;
background-color: #1e7c85;
color: white;
padding: 0px;
position: fixed;
padding: 0;
position: absolute;
height: 6vh;
font-size: 80%;
font-size: 85%;
top: 10%;
left: -15%;
width: 100%;
width: 130%;
float: left;
transform: scale(0.7);
}
Expand Down
Loading

0 comments on commit fa7d6df

Please sign in to comment.