Update to Symfony 4.1 #149 (#160)

* updated to Symfony 4.1 #149
* updated to phpunit 7 #149
* downgrade ocramius/proxy-manager for PHP 7.1 compatibility #149
* fixed symfony deprecations #149
* replaced AdvancedUserInterface with custom user checker
* code sniffer fixes
This commit is contained in:
Kevin Papst
2018-06-18 22:26:00 +02:00
committed by GitHub
parent 4e629fcaf8
commit bfa32a90db
14 changed files with 869 additions and 801 deletions

View File

@@ -9,6 +9,7 @@
"avanzu/admin-theme-bundle": "dev-kevinpapst",
"beberlei/DoctrineExtensions": "^1.0",
"erusev/parsedown": "^1.6",
"ocramius/proxy-manager": "2.1.1",
"sensio/framework-extra-bundle": "^5.1",
"symfony/asset": "^4.0",
"symfony/console": "^4.0",
@@ -36,7 +37,7 @@
"dama/doctrine-test-bundle": "^5.0",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"friendsofphp/php-cs-fixer": "^2.10",
"phpunit/phpunit": "^6.5",
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "^3.2",
"symfony/browser-kit": "^4.0",
"symfony/css-selector": "^4.0",

1502
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,12 +14,12 @@ security:
security: false
secured_area:
# does what it says
logout_on_user_change: true
# this firewall applies to all URLs
pattern: ^/
# make sure only allowed users have access to their time-tracking
user_checker: App\Security\UserChecker
# but the firewall does not require login on every page
# denying access is done in access_control or in your controllers
anonymous: ~

View File

@@ -1,7 +1,14 @@
home:
path: /
defaults:
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
route: homepage
permanent: true
homepage:
path: /{_locale}
defaults:
_controller: FrameworkBundle:Redirect:redirect
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
route: timesheet
permanent: true

View File

@@ -63,14 +63,21 @@ class CreateUserCommand extends Command
*/
protected function configure()
{
$roles = implode(',', [User::DEFAULT_ROLE, User::ROLE_ADMIN]);
$this
->setName('kimai:create-user')
->setDescription('Create a new user')
->setHelp('This command allows you to create a new user.')
->addArgument('username', InputArgument::REQUIRED, 'The username of the user to be created (must be unique)')
->addArgument('email', InputArgument::REQUIRED, 'Email address of the user to be created (must be unique)')
->addArgument('role', InputArgument::OPTIONAL, 'A comma separated list of roles to assign. Examples: "ROLE_USER,ROLE_SUPER_ADMIN"', User::DEFAULT_ROLE)
->addArgument('password', InputArgument::OPTIONAL, 'Password for the user to be created')
->addArgument('username', InputArgument::REQUIRED, 'A name for the new user (must be unique)')
->addArgument('email', InputArgument::REQUIRED, 'Email address of the new user (must be unique)')
->addArgument(
'role',
InputArgument::OPTIONAL,
'A comma separated list of user roles, e.g. "'.$roles.'"',
User::DEFAULT_ROLE
)
->addArgument('password', InputArgument::OPTIONAL, 'Password for the new user (requested if not provided)')
;
}

View File

@@ -35,8 +35,8 @@ class SidebarController extends AbstractController
$user = $this->getUser();
return $this->render('sidebar/settings.html.twig', [
'user' => $user,
]);
'user' => $user,
]);
/*

View File

@@ -134,9 +134,9 @@ trait TimesheetControllerTrait
}
}
// TODO validate that end is not before begin
// TODO validate that end is not before begin
$entityManager = $this->getDoctrine()->getManager();
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($entry);
$entityManager->flush();

View File

@@ -25,7 +25,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
* @UniqueEntity("username")
* @UniqueEntity("email")
*/
class User implements UserInterface, AdvancedUserInterface
class User implements UserInterface
{
const ROLE_CUSTOMER = 'ROLE_CUSTOMER';
const ROLE_USER = 'ROLE_USER';
@@ -405,30 +405,6 @@ class User implements UserInterface, AdvancedUserInterface
return $this;
}
/**
* @inheritdoc
*/
public function isAccountNonExpired()
{
return true;
}
/**
* @inheritdoc
*/
public function isAccountNonLocked()
{
return true;
}
/**
* @inheritdoc
*/
public function isCredentialsNonExpired()
{
return true;
}
/**
* @return bool
*/

View File

@@ -43,10 +43,10 @@ class TimesheetEditForm extends AbstractType
$builder->add('begin', DateTimeType::class, [
'label' => 'label.begin',
'widget' => 'single_text',
'html5' => false,
'format' => 'yyyy-MM-dd H:m',
'with_seconds' => false,
'attr' => ['data-datetimepicker' => 'on'],
'html5' => false,
'format' => 'yyyy-MM-dd H:m',
'with_seconds' => false,
'attr' => ['data-datetimepicker' => 'on'],
]);
}
@@ -57,10 +57,10 @@ class TimesheetEditForm extends AbstractType
'label' => 'label.end',
'widget' => 'single_text',
'required' => false,
'html5' => false,
'format' => 'yyyy-MM-dd H:m',
'with_seconds' => false,
'attr' => ['data-datetimepicker' => 'on'],
'html5' => false,
'format' => 'yyyy-MM-dd H:m',
'with_seconds' => false,
'attr' => ['data-datetimepicker' => 'on'],
]);
}

View File

@@ -110,7 +110,7 @@ abstract class AbstractToolbarForm extends AbstractType
'widget' => 'single_text',
'html5' => false,
'required' => false,
'attr' => ['data-datepicker' => 'on'],
'attr' => ['data-datepicker' => 'on'],
]);
}
@@ -122,9 +122,9 @@ abstract class AbstractToolbarForm extends AbstractType
$builder->add('end', DateType::class, [
'label' => 'label.end',
'widget' => 'single_text',
'html5' => false,
'html5' => false,
'required' => false,
'attr' => ['data-datepicker' => 'on'],
'attr' => ['data-datepicker' => 'on'],
]);
}

View File

@@ -41,7 +41,7 @@ class ActivityRepository extends AbstractRepository
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('t', 'a', 'p', 'c')
->distinct()
->distinct()
->from(Timesheet::class, 't')
->join('t.activity', 'a')
->join('a.project', 'p')
@@ -50,7 +50,7 @@ class ActivityRepository extends AbstractRepository
->andWhere('a.visible = 1')
->andWhere('p.visible = 1')
->andWhere('c.visible = 1')
->groupBy('a.id', 't.id')
->groupBy('a.id', 't.id')
->orderBy('t.end', 'DESC')
->setMaxResults(10)
;

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Security;
use App\Entity\User;
use Symfony\Component\Security\Core\Exception\LockedException;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Advanced checks during aithentication to make sure the user is allowed to use Kimai.
*/
class UserChecker implements UserCheckerInterface
{
public function checkPreAuth(UserInterface $user)
{
}
public function checkPostAuth(UserInterface $user)
{
if (!$user instanceof User) {
return;
}
// user account is not enabled, the user may be notified
if (!$user->isEnabled()) {
throw new LockedException();
}
}
}

View File

@@ -79,22 +79,22 @@ class UserVoter extends AbstractVoter
case self::ROLES:
return $this->canAdminUsers($token);
case self::PREFERENCES:
return $this->canEditPreferences($subject, $user, $token);
return $this->canEditPreferences($subject, $user, $token);
}
return false;
}
/**
* @param User $profile
* @param User $user
* @param TokenInterface $token
* @return bool
*/
/**
* @param User $profile
* @param User $user
* @param TokenInterface $token
* @return bool
*/
protected function canEditPreferences(User $profile, User $user, TokenInterface $token)
{
return $profile->getId() == $user->getId();
}
{
return $profile->getId() == $user->getId();
}
/**
* @param User $profile

View File

@@ -11,6 +11,9 @@
"composer/semver": {
"version": "1.4.2"
},
"composer/xdebug-handler": {
"version": "1.1.0"
},
"dama/doctrine-test-bundle": {
"version": "4.0",
"recipe": {
@@ -113,9 +116,6 @@
"ref": "bb31a3bbec00a8fc8aa1c9fbf9b0ef9fc492f93d"
}
},
"gecko-packages/gecko-php-unit": {
"version": "v3.0"
},
"jdorn/sql-formatter": {
"version": "v1.2.17"
},
@@ -125,6 +125,9 @@
"myclabs/deep-copy": {
"version": "1.7.0"
},
"nikic/php-parser": {
"version": "v4.0.2"
},
"ocramius/package-versions": {
"version": "1.2.0"
},
@@ -179,9 +182,6 @@
"ref": "9d0927a518f631b4ae6508dac377b021761ff6d1"
}
},
"phpunit/phpunit-mock-objects": {
"version": "5.0.6"
},
"psr/cache": {
"version": "1.0.1"
},
@@ -377,6 +377,9 @@
"ref": "179470cb6492db92dffee208cfdb436f175c93b4"
}
},
"symfony/polyfill-ctype": {
"version": "v1.8.0"
},
"symfony/polyfill-intl-icu": {
"version": "v1.6.0"
},
@@ -404,9 +407,6 @@
"ref": "cda8b550123383d25827705d05a42acf6819fe4e"
}
},
"symfony/security": {
"version": "v4.0.3"
},
"symfony/security-bundle": {
"version": "3.3",
"recipe": {