Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit bf1330e

Browse files
Release 2.3.1 (#1158)
* Parent + Nested validation changes (#1138) * #1121 (#1126) * Public Role : UserId should be set 0 instead of null * Change : invalid token * Issue Fix #1109 (#1146) * Added file support for 7.0 (Explained) (#1124) * Bump version to 2.3.0 (#1120) * Added file support for 7.0 (Explained) Having `public` in front of `const` completely breaks the application for `PHP 7.0` usage, which broke everything when I pulled origin. Though I understand `PHP 7.0` isn't officially supported, and that `PHP 7.1+` is, there is no reason to use public alongside const as the default visibility of class constants are public. We might as well provide support where possible if it doesn't hurt. Explained here: https://stackoverflow.com/a/51568547 * Issue Fix #1114 (#1128) * Issue Fix #1114 * Change exception message * Update .gitignore (#1129) * Bump version to 2.3.0 (#1120) * Update .gitignore * Update .gitignore * Update .gitignore * Update .gitignore * Issue Fix #1125 (#1134) * Issue Fix #1131 (#1135) * create thumb for pdf if imagick is available (#1123) * Bump version to 2.3.0 (#1120) * create thumb for pdf if imagick is available * Issue Fix #1109 * Add Special characters in the radom string generator * Issue Fix #1109 * Remove other option * Imagick changes * Issue Fix #1148 (#1152) * Fix 1149 (#1156) * Process relation & non relatinal fields sequentially to solve logical operator issue * Process relation & non relatinal fields sequentially to solve logical operator issue * Fixed namespace of InvalidLoggerConfigurationException (#1153) * Bump version to v2.3.1
1 parent ff05f58 commit bf1330e

File tree

19 files changed

+386
-63
lines changed

19 files changed

+386
-63
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ composer.phar
1717
composer.lock
1818
/vendor
1919

20+
# Exclude env vars and custom deployment scripts
21+
.env
22+
deploy.*
23+
2024
# Ignore configuration files
2125
/config/*
2226
!/config/migrations.php
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
4+
use Phinx\Migration\AbstractMigration;
5+
6+
class PasswordValidationSettingField extends AbstractMigration
7+
{
8+
public function up()
9+
{
10+
$conn = $this->getAdapter()->getConnection();
11+
12+
$fieldObject = [
13+
'field' => 'password_policy',
14+
'type' => 'string',
15+
'note' => 'Weak : Minimum length 8; Strong : 1 small-case letter, 1 capital letter, 1 digit, 1 special character and the length should be minimum 8',
16+
'interface' => 'dropdown',
17+
'options' => ['choices' => ['' => 'None', '/^.{8,}$/' => 'Weak', '/(?=^.{8,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{\';\'?>.<,])(?!.*\s).*$/' => 'Strong']]
18+
];
19+
$collection = 'directus_settings';
20+
$checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $fieldObject['field']);
21+
$result = $this->query($checkSql)->fetch();
22+
if (!$result) {
23+
$insertSqlFormat = "INSERT INTO `directus_fields` (`collection`, `field`, `type`, `interface`, `options`, `note`) VALUES ('%s', '%s', '%s', '%s' , %s, '%s');";
24+
$insertSql = sprintf($insertSqlFormat, $collection, $fieldObject['field'], $fieldObject['type'], $fieldObject['interface'], $conn->quote(json_encode($fieldObject['options'])) , $fieldObject['note']);
25+
$this->execute($insertSql);
26+
}
27+
28+
}
29+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
4+
use Phinx\Migration\AbstractMigration;
5+
6+
class UpdateNoteForDefaultLimit extends AbstractMigration
7+
{
8+
public function up()
9+
{
10+
$this->execute(\Directus\phinx_update(
11+
$this->getAdapter(),
12+
'directus_fields',
13+
[
14+
'note' => 'The color that best fits your brand.'
15+
],
16+
['collection' => 'directus_settings', 'field' => 'color']
17+
));
18+
19+
$this->execute(\Directus\phinx_update(
20+
$this->getAdapter(),
21+
'directus_fields',
22+
[
23+
'note' => 'Default max amount of items that\'s returned at a time in the API.'
24+
],
25+
['collection' => 'directus_settings', 'field' => 'default_limit']
26+
));
27+
28+
$this->execute(\Directus\phinx_update(
29+
$this->getAdapter(),
30+
'directus_fields',
31+
[
32+
'width' => 'half',
33+
],
34+
['collection' => 'directus_settings', 'field' => 'password_policy']
35+
));
36+
37+
$this->execute(\Directus\phinx_update(
38+
$this->getAdapter(),
39+
'directus_fields',
40+
[
41+
'width' => 'half',
42+
],
43+
['collection' => 'directus_settings', 'field' => 'file_max_size']
44+
));
45+
46+
}
47+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@directus/api",
33
"private": true,
4-
"version": "2.3.0",
4+
"version": "2.3.1",
55
"description": "Directus API",
66
"main": "index.js",
77
"repository": "directus/api",

src/core/Directus/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Application extends App
1313
*
1414
* @var string
1515
*/
16-
const DIRECTUS_VERSION = '2.3.0';
16+
const DIRECTUS_VERSION = '2.3.1';
1717

1818
/**
1919
* NOT USED

src/core/Directus/Application/CoreServicesProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,14 @@ protected function getEmitter()
321321
$files = $container->get('files');
322322

323323
$fileData = ArrayUtils::get($data, 'data');
324+
325+
$dataInfo = [];
324326
if (is_a_url($fileData)) {
325327
$dataInfo = $files->getLink($fileData);
326328
// Set the URL payload data
327329
$payload['data'] = ArrayUtils::get($dataInfo, 'data');
328330
$payload['filename'] = ArrayUtils::get($dataInfo, 'filename');
329-
} else {
331+
} else if(!is_object($fileData)) {
330332
$dataInfo = $files->getDataInfo($fileData);
331333
}
332334

src/core/Directus/Application/Http/Middleware/AuthenticationMiddleware.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,7 @@ public function __invoke(Request $request, Response $response, callable $next)
5353

5454
if (!is_null($user)) {
5555
$rolesIpWhitelist = $this->getUserRolesIPWhitelist($user->getId());
56-
$permissionsByCollection = $permissionsTable->getUserPermissions($user->getId());
57-
58-
// TODO: Adding an user should auto set its ID and GROUP
59-
// TODO: User data should be casted to its data type
60-
// TODO: Make sure that the group is not empty
61-
$acl->setUserId($user->getId());
62-
$acl->setUserEmail($user->getEmail());
63-
$acl->setUserFullName($user->get('first_name') . ' ' . $user->get('last_name'));
64-
56+
$permissionsByCollection = $permissionsTable->getUserPermissions($user->getId());
6557
$hookEmitter->run('auth.success', [$user]);
6658
} else {
6759
if (is_null($user) && $publicRoleId) {
@@ -102,9 +94,13 @@ public function __invoke(Request $request, Response $response, callable $next)
10294
$hookEmitter->run('auth.fail', [$exception]);
10395
throw $exception;
10496
}
105-
106-
107-
97+
98+
// TODO: Adding an user should auto set its ID and GROUP
99+
// TODO: User data should be casted to its data type
100+
// TODO: Make sure that the group is not empty
101+
$acl->setUserId($user->getId());
102+
$acl->setUserEmail($user->getEmail());
103+
$acl->setUserFullName($user->get('first_name') . ' ' . $user->get('last_name'));
108104

109105
return $next($request, $response);
110106
}

src/core/Directus/Config/Schema/Types.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88
interface Types
99
{
10-
public const INTEGER = 'number';
11-
public const FLOAT = 'float';
12-
public const STRING = 'string';
13-
public const BOOLEAN = 'boolean';
10+
const INTEGER = 'number';
11+
const FLOAT = 'float';
12+
const STRING = 'string';
13+
const BOOLEAN = 'boolean';
1414
}

src/core/Directus/Console/Common/User.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Directus\Console\Common\Exception\UserUpdateException;
88
use Zend\Db\TableGateway\TableGateway;
99
use Directus\Util\Installation\InstallerUtils;
10+
use function Directus\get_directus_setting;
1011

1112
class User
1213
{
@@ -74,6 +75,14 @@ public function changePassword($email, $password)
7475
{
7576

7677
$auth = $this->app->getContainer()->get('auth');
78+
79+
$passwordValidation = get_directus_setting('password_policy');
80+
if(!empty($passwordValidation)){
81+
if(!preg_match($passwordValidation, $password, $match)){
82+
throw new PasswordChangeException('Password is not valid.');
83+
}
84+
}
85+
7786
$hash = $auth->hashPassword($password);
7887
$user = $this->usersTableGateway->select(['email' => $email])->current();
7988

0 commit comments

Comments
 (0)