Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed Mar 17, 2020
0 parents commit 71370be
Show file tree
Hide file tree
Showing 261 changed files with 17,175 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/.travis.yml export-ignore
/Changelog.md export-ignore
/Makefile export-ignore
/README.md export-ignore
/Tests export-ignore
/Upgrade.md export-ignore
/phpunit.xml.dist export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.php_cs
.php_cs.cache
composer.lock
phpunit.xml
vendor/
.idea/
33 changes: 33 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

$header = <<<EOF
This file is part of the FOSUserBundle package.
(c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'header_comment' => ['header' => $header],
'linebreak_after_opening_tag' => true,
'no_php4_constructor' => true,
'no_useless_else' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_strict' => true,
'phpdoc_no_empty_return' => false,
])
->setUsingCache(true)
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
)
;
15 changes: 15 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Changelog
=========

### 3.0

- changed package name to `kimai/user-bundle`
- removed support for mongo db
- removed support for couch db
- removed docs
- replaced deprecated twig usages from `\Twig_` namespace
- removed usage of deprecated `AdvancedUserInterface`
- removed support for deprecated `BCryptPasswordEncoder`
- replaced deprecated extends from `Controller` with `AbstractController`

See changelog for [FOSUserBundle](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Changelog.md) for all previous versions.
89 changes: 89 additions & 0 deletions Command/ActivateUserCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\UserBundle\Command;

use FOS\UserBundle\Util\UserManipulator;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

/**
* @author Antoine Hérault <[email protected]>
*/
class ActivateUserCommand extends Command
{
protected static $defaultName = 'fos:user:activate';

private $userManipulator;

public function __construct(UserManipulator $userManipulator)
{
parent::__construct();

$this->userManipulator = $userManipulator;
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('fos:user:activate')
->setDescription('Activate a user')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
])
->setHelp(<<<'EOT'
The <info>fos:user:activate</info> command activates a user (so they will be able to log in):
<info>php %command.full_name% matthieu</info>
EOT
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$username = $input->getArgument('username');

$this->userManipulator->activate($username);

$output->writeln(sprintf('User "%s" has been activated.', $username));

return 0;
}

/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
if (!$input->getArgument('username')) {
$question = new Question('Please choose a username:');
$question->setValidator(function ($username) {
if (empty($username)) {
throw new \Exception('Username can not be empty');
}

return $username;
});
$answer = $this->getHelper('question')->ask($input, $output, $question);

$input->setArgument('username', $answer);
}
}
}
113 changes: 113 additions & 0 deletions Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\UserBundle\Command;

use FOS\UserBundle\Util\UserManipulator;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

class ChangePasswordCommand extends Command
{
protected static $defaultName = 'fos:user:change-password';

private $userManipulator;

public function __construct(UserManipulator $userManipulator)
{
parent::__construct();

$this->userManipulator = $userManipulator;
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('fos:user:change-password')
->setDescription('Change the password of a user.')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
new InputArgument('password', InputArgument::REQUIRED, 'The password'),
])
->setHelp(<<<'EOT'
The <info>fos:user:change-password</info> command changes the password of a user:
<info>php %command.full_name% matthieu</info>
This interactive shell will first ask you for a password.
You can alternatively specify the password as a second argument:
<info>php %command.full_name% matthieu mypassword</info>

EOT
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$username = $input->getArgument('username');
$password = $input->getArgument('password');

$this->userManipulator->changePassword($username, $password);

$output->writeln(sprintf('Changed password for user <comment>%s</comment>', $username));

return 0;
}

/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$questions = [];

if (!$input->getArgument('username')) {
$question = new Question('Please give the username:');
$question->setValidator(function ($username) {
if (empty($username)) {
throw new \Exception('Username can not be empty');
}

return $username;
});
$questions['username'] = $question;
}

if (!$input->getArgument('password')) {
$question = new Question('Please enter the new password:');
$question->setValidator(function ($password) {
if (empty($password)) {
throw new \Exception('Password can not be empty');
}

return $password;
});
$question->setHidden(true);
$questions['password'] = $question;
}

foreach ($questions as $name => $question) {
$answer = $this->getHelper('question')->ask($input, $output, $question);
$input->setArgument($name, $answer);
}
}
}
Loading

0 comments on commit 71370be

Please sign in to comment.