Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tp.config.php by ConfigManager and remove obsoletes functions. #4372

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions api/Model/AuthModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

use TeampassClasses\PasswordManager\PasswordManager;
use TeampassClasses\NestedTree\NestedTree;
use TeampassClasses\ConfigManager\ConfigManager;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;

Expand Down Expand Up @@ -83,8 +84,11 @@ public function getUserAuth(string $login, string $password, string $apikey): ar
return ["error" => "Login failed.", "info" => "User not allowed to use API"];
}

// Load config
$configManager = new ConfigManager();
$SETTINGS = $configManager->getAllSettings();

// Log user
include API_ROOT_PATH . '/../includes/config/tp.config.php';
logEvents($SETTINGS, 'api', 'user_connection', (string) $apiInfo['increment_id'], stripslashes($inputData['login']));

// create JWT
Expand Down Expand Up @@ -153,8 +157,11 @@ public function getUserAuth(string $login, string $password, string $apikey): ar
// get user folders list
$ret = $this->buildUserFoldersList($userInfo);

// Load config
$configManager = new ConfigManager();
$SETTINGS = $configManager->getAllSettings();

// Log user
include API_ROOT_PATH . '/../includes/config/tp.config.php';
logEvents($SETTINGS, 'api', 'user_connection', (string) $userInfo['id'], stripslashes($userInfo['login']));

// create JWT
Expand Down Expand Up @@ -228,7 +235,9 @@ private function createUserJWT(
int $allowed_to_delete,
): array
{
include API_ROOT_PATH . '/../includes/config/tp.config.php';
// Load config
$configManager = new ConfigManager();
$SETTINGS = $configManager->getAllSettings();

$payload = [
'username' => $login,
Expand Down
6 changes: 5 additions & 1 deletion api/Model/ItemModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

use TeampassClasses\NestedTree\NestedTree;
use TeampassClasses\ConfigManager\ConfigManager;
use ZxcvbnPhp\Zxcvbn;

require_once API_ROOT_PATH . "/Model/Database.php";
Expand Down Expand Up @@ -148,7 +149,10 @@ public function addItem(
{
try {
include_once API_ROOT_PATH . '/../sources/main.functions.php';
include API_ROOT_PATH . '/../includes/config/tp.config.php';

// Load config
$configManager = new ConfigManager();
$SETTINGS = $configManager->getAllSettings();

// Step 1: Prepare data and sanitize inputs
$data = $this->prepareData($folderId, $label, $password, $description, $login, $email, $url, $tags, $anyone_can_modify, $icon);
Expand Down
8 changes: 4 additions & 4 deletions api/inc/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@
* @see https://www.teampass.net
*/

use TeampassClasses\ConfigManager\ConfigManager;

define("API_ROOT_PATH", __DIR__ . "/..");

// include main configuration file
require API_ROOT_PATH . '/../sources/main.functions.php';

// init
loadClasses('DB');

// include the base controller file
require API_ROOT_PATH . "/Controller/Api/BaseController.php";

Expand Down Expand Up @@ -108,7 +106,9 @@ function checkUSerCRUDRights($userData, $actionToPerform): bool
*/
function apiIsEnabled(): string
{
include API_ROOT_PATH . '/../includes/config/tp.config.php';
// Load config
$configManager = new ConfigManager();
$SETTINGS = $configManager->getAllSettings();

if (isset($SETTINGS) === true && isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) {
return json_encode(
Expand Down
1 change: 0 additions & 1 deletion docs/install/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ git pull
* Copy next files from `folderv2` to `folderv3`
```
./includes/config/settings.php
./includes/config/tp.config.php
./includes/libraries/csrfp/libs/csrfp.config.php
./includes/teampass-seckey.txt
./includes/avatars/*
Expand Down
2 changes: 1 addition & 1 deletion includes/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function jsonErrorHdl(message)
function prepareExchangedData(data, type, key, fileName = '', functionName = '')
{
if (type === 'decode') {
if (parseInt($('#encryptClientServer').val()) === 0) {
if (parseInt($('input#encryptClientServer').val()) === 0) {
try {
return $.parseJSON(data);
}
Expand Down
Loading