浏览代码

Remove the session when the password is changed

FusionPBX 10 月之前
父节点
当前提交
4f1e217bb4
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      core/users/user_edit.php

+ 13 - 0
core/users/user_edit.php

@@ -517,6 +517,19 @@
 				$array['users'][$x]['username'] = $username;
 				$array['users'][$x]['username'] = $username;
 			}
 			}
 			if (permission_exists('user_password') && !empty($password) && $password == $password_confirm) {
 			if (permission_exists('user_password') && !empty($password) && $password == $password_confirm) {
+				//remove the session id files
+				$sql = "select session_id from v_user_logs ";
+				$sql .= "where user_uuid = :user_uuid ";
+				$sql .= "and timestamp > NOW() - INTERVAL '4 hours' ";
+				$parameters['user_uuid'] = $user_uuid;
+				$user_logs = $database->select($sql, $parameters, 'all');
+				foreach ($user_logs as $row) {
+					if (preg_match('/^[a-zA-Z0-9,-]+$/', $row['session_id']) && file_exists(session_save_path() . "/sess_" . $row['session_id'])) {
+						unlink(session_save_path() . "/sess_" . $row['session_id']);
+					}
+				}
+
+				//create a one way hash for the user password
 				$array['users'][$x]['password'] = password_hash($password, PASSWORD_DEFAULT, $options);
 				$array['users'][$x]['password'] = password_hash($password, PASSWORD_DEFAULT, $options);
 				$array['users'][$x]['salt'] = null;
 				$array['users'][$x]['salt'] = null;
 			}
 			}