Browse code

Changed majority of files.

DoubleBastionAdmin authored on 30/11/2024 06:56:40
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,53 @@
1
+<?php
2
+/**
3
+ *  Copyright (C) 2021  Double Bastion LLC
4
+ *
5
+ *  This file is part of Roundpin, which is licensed under the
6
+ *  GNU Affero General Public License Version 3.0. The license terms
7
+ *  are detailed in the "LICENSE.txt" file located in the root directory.
8
+ */
9
+
10
+session_start();
11
+ // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
12
+
13
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
14
+
15
+ define('ACCESSCONST', TRUE);
16
+
17
+ require('db-connect.php');
18
+
19
+    $username = $_POST['username'];
20
+    $currentPassword = $_POST['current_password'];
21
+    $newPassword = $_POST['new_password'];
22
+
23
+    // Get the password of the current user from the 'app_users' table
24
+    $enabled = 1;
25
+    $querypass = $mysqli->prepare("SELECT id, username, password, enabled FROM app_users WHERE BINARY username=? AND enabled=?");
26
+    $querypass->bind_param("si", $username, $enabled);
27
+    $querypass->execute();
28
+    $fetchData = $querypass->get_result();
29
+    $passdatafromdb = $fetchData->fetch_row();
30
+    $fetchedpassfromdb = $passdatafromdb[2];
31
+
32
+    $changepassverify = password_verify($currentPassword, $fetchedpassfromdb);
33
+
34
+    if ($changepassverify) {
35
+
36
+        $newHashedPassword = password_hash($newPassword, PASSWORD_DEFAULT);
37
+        $enabled = 1;
38
+        $queryupdatepass = $mysqli->prepare("UPDATE app_users SET password=? WHERE BINARY username=? AND enabled=?");
39
+        $queryupdatepass->bind_param("ssi", $newHashedPassword, $username, $enabled);
40
+
41
+        if ($queryupdatepass->execute()) { 
42
+            $passchangemessage = "Your Roundpin user password has been updated successfully. From now on you will have to use your new password to log in to Roundpin.";
43
+        } else { $passchangemessage = "An error occurred while attempting to save the new password!"; }
44
+
45
+    } else { $passchangemessage = "The password you have entered in the 'Current Password' field doesn't match your current password!"; }
46
+
47
+    echo json_encode($passchangemessage);
48
+
49
+} else {
50
+    header("Location: ../login.php");
51
+}
52
+
53
+?>
0 54
\ No newline at end of file