Skip to content

Commit

Permalink
Merge pull request #36 from Wolframcheg/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Wolframcheg committed Mar 22, 2016
2 parents 2e0eb3f + 3682a5c commit b2b0326
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 71 deletions.
13 changes: 8 additions & 5 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ doctrine:

# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
transport: %mailer_transport%
host: %mailer_host%
port: %mailer_port%
username: %mailer_user%
encryption: %mailer_encryption%
auth_mode: %mailer_auth_mode%
password: %mailer_password%


stof_doctrine_extensions:
default_locale: en_US
Expand Down
4 changes: 3 additions & 1 deletion app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ parameters:
mailer_host: 127.0.0.1
mailer_user: ~
mailer_password: ~
mailer_from: ~
mailer_encryption: ssl
mailer_auth_mode: login
mailer_port: 465
# A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt

Expand Down
2 changes: 1 addition & 1 deletion app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ security:
google: "/login/check-google"
login_path: /
use_forward: false
default_target_path: /registrationNet
default_target_path: /account/update-profile
failure_path: /
oauth_user_provider:
service: oauth_test_provider
Expand Down
2 changes: 1 addition & 1 deletion app/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<argument type="service" id="mailer" />
<argument type="service" id="templating" />
<argument type="service" id="app.random.generator" />
<argument>%mailer_from%</argument>
<argument>%mailer_user%</argument>
</service>

<service id="app.random.generator" class="AppBundle\Services\RandomGenerator" />
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ case "$Keypress" in
composer install
./node_modules/.bin/bower install
./node_modules/.bin/gulp
php app/console doctrine:database:drop --force
php app/console doctrine:database:create
#php app/console doctrine:database:drop --force
#php app/console doctrine:database:create
php app/console doctrine:schema:update --force
app/console app:admin_create admin@admin.net admin Admin Admin
;;
Expand Down
14 changes: 7 additions & 7 deletions src/AppBundle/Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function registerAction(Request $request)
}

/**
* @Route("/registrationNet", name="net_registration")
* @Route("/account/update-profile", name="update_profile")
* @Template("@App/registration/updateRegistration.html.twig")
*/
public function registerSocialNetAction(Request $request)
{
$user = $this->getUser();

if ($user) {
if ($user->getIsReg() === false) {
if (!$user->getPassword()) {
return $this->get('app.registration.user')
->updateRegistrationUser($request, $user);
}
Expand Down Expand Up @@ -78,8 +78,7 @@ public function checkUserHash($hash, $email)
->findOneBy(array('email' => $email, 'hash' => $hash));

if ($user) {

$user->setIsReg(true);
$user->setIsActive(true);
$user->setHash(null);
$this->addFlash('notice', 'You have successfully passed registration confirmation');

Expand All @@ -106,11 +105,12 @@ public function recoveryPassword(Request $request)
$user = $em->getRepository('AppBundle:User')
->findOneBy(['email' => $email]);

if ($user && $user->getIsReg() == true) {
if ($user && $user->isAccountNonLocked() == true) {
$password = $this->get('app.custom.mailer')->sendMailRecovery($email);
$newPassword = $this->get('security.password_encoder')
->encodePassword($user, $password);
$user->setPassword($newPassword);
$user->setIsActive(true);

$em->flush();
$this->addFlash('notice', 'The new password is sent to your email');
Expand All @@ -121,8 +121,8 @@ public function recoveryPassword(Request $request)
$this->addFlash('notice', 'Email is incorrectly specified');

return $this->redirectToRoute('homepage');
} elseif ($user && $user->getIsReg() == false) {
$this->addFlash('notice', 'You aren\'t registered');
} elseif ($user && $user->isAccountNonLocked() == false) {
$this->addFlash('notice', 'You are blocked');

return $this->redirectToRoute('homepage');
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/AppBundle/DataFixtures/ORM/Data/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ AppBundle\Entity\User:
email(unique): user1@mail.ru
password: <encodePassword(@user1, "userpass")>
role: ROLE_USER
isReg: true
isActive: true
user2:
firstName: <name()>
lastName: <lastName()>
email(unique): user2@mail.ru
password: <encodePassword(@user2, "userpass")>
role: ROLE_USER
isReg: true
isActive: true
user3:
firstName: <name()>
lastName: <lastName()>
email(unique): user3@mail.ru
password: <encodePassword(@user3, "userpass")>
role: ROLE_USER
isReg: true
isActive: true
4 changes: 2 additions & 2 deletions src/AppBundle/DataFixtures/ORM/DataForTests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ AppBundle\Entity\User:
password: <encodePassword(@user1, "user")>
email: admin@test.com
isActive: true
isReg: true
role: "ROLE_ADMIN"
firstName: "Admin"
lastName: "Admin"
isActive: true
user2:
password: <encodePassword(@user2, "user")>
email: user@test.com
isActive: true
isReg: true
role: "ROLE_USER"
firstName: "User"
lastName: "User"
isActive: true

AppBundle\Entity\Category:
category1:
Expand Down
52 changes: 26 additions & 26 deletions src/AppBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class User implements AdvancedUserInterface, \JsonSerializable
protected $type;

/**
* @ORM\Column(name="is_reg", type="boolean")
* @ORM\Column(name="is_locked", type="boolean")
*/
protected $isReg;
protected $isLocked;

/**
* @ORM\Column(name="hash", type="string", nullable=true)
Expand All @@ -121,14 +121,10 @@ public function jsonSerialize()
];
}


/**
*
*/
public function __construct()
{
$this->isActive = false;
$this->isReg = false;
$this->isLocked = false;
$this->modulesUser = new ArrayCollection();
$this->role = self::ROLE_USER;
}
Expand Down Expand Up @@ -324,7 +320,7 @@ public function isAccountNonExpired()
*/
public function isAccountNonLocked()
{
return true;
return $this->isLocked ? false : true ;
}

/**
Expand Down Expand Up @@ -360,6 +356,23 @@ public function setIsActive($active)
return $this->isActive = $active;
}

/**
* @return bool
*/
public function getIsLocked()
{
return $this->isLocked;
}

/**
* @param $isLocked
* @return mixed
*/
public function setIsLocked($isLocked)
{
return $this->isLocked = $isLocked;
}

/**
* @return string
*/
Expand All @@ -370,6 +383,7 @@ public function getFacebookToken()

/**
* @param string $facebookToken
* @return $this
*/
public function setFacebookToken($facebookToken)
{
Expand All @@ -388,6 +402,7 @@ public function getFacebookId()

/**
* @param string $facebookId
* @return $this
*/
public function setFacebookId($facebookId)
{
Expand All @@ -406,6 +421,7 @@ public function getGoogleToken()

/**
* @param string $googleToken
* @return $this
*/
public function setGoogleToken($googleToken)
{
Expand All @@ -424,6 +440,7 @@ public function getGoogleId()

/**
* @param string $googleId
* @return $this
*/
public function setGoogleId($googleId)
{
Expand Down Expand Up @@ -456,24 +473,6 @@ public function getType()
return $this->type;
}

/**
* @return mixed
*/
public function getIsReg()
{
return $this->isReg;
}

/**
* @param mixed $isReg
*/
public function setIsReg($isReg)
{
$this->isReg = $isReg;

return $this;
}

/**
* @return mixed
*/
Expand All @@ -484,6 +483,7 @@ public function getHash()

/**
* @param mixed $hash
* @return $this
*/
public function setHash($hash)
{
Expand Down
1 change: 1 addition & 0 deletions src/AppBundle/Form/UpdateUserSocialNetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
])
->add('plain_password', RepeatedType::class, [
'type' => PasswordType::class,
'required' => false,
'invalid_message' => 'The password fields must match.',
'options' => [
'attr' => [
Expand Down
4 changes: 2 additions & 2 deletions src/AppBundle/Form/UpdateUserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'placeholder' => 'enter last name'
]
])
->add('is_active', CheckboxType::class, [
'label' => 'Active',
->add('is_locked', CheckboxType::class, [
'label' => 'Locked',
'required' => false
]);
}
Expand Down
8 changes: 3 additions & 5 deletions src/AppBundle/Form/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('email', EmailType::class, [
'attr' => [
'class' => 'form-control',
'placeholder' => 'enter email'
]
])
->add('firstName', TextType::class, [
'attr' => [
'class' => 'form-control',
'placeholder' => 'enter first name'
]
])
->add('lastName', TextType::class, [
'attr' => [
'class' => 'form-control',
'placeholder' => 'enter last name'
]
])
->add('plain_password', RepeatedType::class, [
Expand All @@ -39,9 +36,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'options' => [
'attr' => [
'class' => 'form-control',
'placeholder' => 'enter password'
]
]
],
'first_options' => ['label' => 'Password'],
'second_options' => ['label' => 'Repeat Password'],
]
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3>You did it! You registered!</h3>

{# example, assuming you have a route named "login" #}
For completion of registration follow the link: <a href="{{ path('register_check_hash', {'hash' : hash, 'email' : email}) }}">CHECK REGISTER</a>.
For completion of registration follow the link: <a href="{{ url('register_check_hash', {'hash' : hash, 'email' : email}) }}">CHECK REGISTER</a>.

Thanks!
2 changes: 2 additions & 0 deletions src/AppBundle/Resources/views/admin/user/showUser.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<th>First Name</th>
<th>Last Name</th>
<th>Active</th>
<th>Locked</th>
<th width="50px">Info</th>
<th width="70px">Modules</th>
<th width="50px">Edit</th>
Expand All @@ -24,6 +25,7 @@
<td>{{ user.firstName }}</td>
<td>{{ user.lastName }}</td>
<td>{% if user.isEnabled %}YES{% else %}NO{% endif %}</td>
<td>{% if user.isLocked %}YES{% else %}NO{% endif %}</td>
<td class="text-center"><a href="{{ path('admin_account', {'id' : user.id }) }}"><i class="glyphicon glyphicon-search"></i></a></td>
<td class="text-center"><a href="{{ path('create_moduleUser', {'idUser': user.id }) }}">
<i class="fa fa-mortar-board"></i></a> ({{ user.countModules }})</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{ form_widget(form) }}
{{ form_rest(form) }}
<br/>
<input type="submit" VALUE="Register" class="btn btn-large btn-primary" id="submit">
<input type="submit" VALUE="Update Profile" class="btn btn-large btn-primary" id="submit">
{{ form_end(form) }}
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/AppBundle/Services/AdminCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function create($email, $password, $firstName, $lastName)
$user->setPassword($pass);
$user->setRole($role);
$user->setIsActive(true);
$user->setIsReg(true);
$em->persist($user);
$em->flush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Services/MailerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function sendMailRecovery($mailTo)
{
$password = $this->generator->generator();
$message = \Swift_Message::newInstance()
->setSubject('Registration')
->setSubject('Recovery')
->setFrom($this->mailerFrom)
->setTo($mailTo)
->setBody(
Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Services/PassControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function process(array $data)
}

$passModule->setCurrentQuestion($nextQuestionForPass);
$this->doctrine->getEntityManager()->flush();
$this->doctrine->getManager()->flush();

return $this->generateOutput('redirect_to_pass', 301, $data['idPassModule']);
}
Expand Down

0 comments on commit b2b0326

Please sign in to comment.