@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | class LoginController extends BaseRestController implements PublicControllerInterface |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Send an email with a link to reset user's password. |
|
| 29 | - * |
|
| 30 | - * @ApiDoc( |
|
| 31 | - * description="Send an email with a link to reset user's password." |
|
| 32 | - * ) |
|
| 33 | - * @Post("password/email/reset", options={"i18n"=false}) |
|
| 34 | - */ |
|
| 27 | + /** |
|
| 28 | + * Send an email with a link to reset user's password. |
|
| 29 | + * |
|
| 30 | + * @ApiDoc( |
|
| 31 | + * description="Send an email with a link to reset user's password." |
|
| 32 | + * ) |
|
| 33 | + * @Post("password/email/reset", options={"i18n"=false}) |
|
| 34 | + */ |
|
| 35 | 35 | public function resetPasswordEmailAction(Request $request): Response |
| 36 | 36 | { |
| 37 | 37 | $email = $request->request->get('email'); |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | return $this->handleView($view); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Reset password view. |
|
| 71 | - * |
|
| 72 | - * @ApiDoc( |
|
| 73 | - * description="Reset password view." |
|
| 74 | - * ) |
|
| 75 | - * @Get("password/reset", options={"i18n"=false}) |
|
| 76 | - */ |
|
| 69 | + /** |
|
| 70 | + * Reset password view. |
|
| 71 | + * |
|
| 72 | + * @ApiDoc( |
|
| 73 | + * description="Reset password view." |
|
| 74 | + * ) |
|
| 75 | + * @Get("password/reset", options={"i18n"=false}) |
|
| 76 | + */ |
|
| 77 | 77 | public function resetPasswordGetAction(Request $request): Response |
| 78 | 78 | { |
| 79 | 79 | $token = $request->query->get('token'); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $email = $request->request->get('email'); |
| 38 | 38 | $user = $this->getEntityManager()->getRepository('Webcook\Cms\SecurityBundle\Entity\User')->findOneBy(array('email'=> $email)); |
| 39 | 39 | |
| 40 | - if($user === null) { |
|
| 40 | + if ($user === null) { |
|
| 41 | 41 | $view = $this->getViewWithMessage(null, 404, 'This email does not exist. Please enter a valid email.'); |
| 42 | 42 | return $this->handleView($view); |
| 43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | ->setContentType("text/html"); |
| 58 | 58 | |
| 59 | 59 | $result = $this->get('mailer')->send($message); |
| 60 | - if($result) { |
|
| 60 | + if ($result) { |
|
| 61 | 61 | $view = $this->getViewWithMessage(null, 200, 'Your password reset link was sent to your e-mail address.'); |
| 62 | 62 | } else { |
| 63 | 63 | $view = $this->getViewWithMessage(null, 400, 'Cannot send an email.'); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $token = $request->query->get('token'); |
| 80 | 80 | $user = $this->getEntityManager()->getRepository('Webcook\Cms\SecurityBundle\Entity\User')->findOneBy(array('passwordResetToken'=> $token)); |
| 81 | - if($user === null || empty($token)){ |
|
| 81 | + if ($user === null || empty($token)) { |
|
| 82 | 82 | $view = $this->getViewWithMessage(null, 404, 'This token is invalid.'); |
| 83 | 83 | return $this->handleView($view); |
| 84 | 84 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $view = $this->getViewWithMessage(null, 400, 'This token has expired.'); |
| 92 | 92 | $diffInSeconds = $dateDiff->i * 60 + $dateDiff->s; |
| 93 | - if($diffInSeconds < 600 && $dateDiff->y == 0 && $dateDiff->m == 0 && $dateDiff->d == 0 && $dateDiff->h == 0) { |
|
| 93 | + if ($diffInSeconds < 600 && $dateDiff->y == 0 && $dateDiff->m == 0 && $dateDiff->d == 0 && $dateDiff->h == 0) { |
|
| 94 | 94 | $view = $this->getViewWithMessage(null, 200, 'Please enter your new password.'); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | $password = $request->request->get('password'); |
| 111 | 111 | $repeatPassword = $request->request->get('repeatPassword'); |
| 112 | 112 | $token = $request->request->get('token'); |
| 113 | - if(empty($password) || empty($repeatPassword) || empty($token)){ |
|
| 113 | + if (empty($password) || empty($repeatPassword) || empty($token)) { |
|
| 114 | 114 | $view = $this->getViewWithMessage(null, 400, 'Passwords and token can\'t be empty.'); |
| 115 | 115 | return $this->handleView($view); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if($password == $repeatPassword) { |
|
| 118 | + if ($password == $repeatPassword) { |
|
| 119 | 119 | $user = $this->getEntityManager()->getRepository('Webcook\Cms\SecurityBundle\Entity\User')->findOneBy(array('passwordResetToken'=> $token)); |
| 120 | - if($user === null){ |
|
| 120 | + if ($user === null) { |
|
| 121 | 121 | $view = $this->getViewWithMessage(null, 404, 'This token is invalid.'); |
| 122 | 122 | return $this->handleView($view); |
| 123 | 123 | } |
@@ -322,11 +322,11 @@ |
||
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Get passwordResetToken. |
|
| 327 | - * |
|
| 328 | - * @inheritDoc |
|
| 329 | - */ |
|
| 325 | + /** |
|
| 326 | + * Get passwordResetToken. |
|
| 327 | + * |
|
| 328 | + * @inheritDoc |
|
| 329 | + */ |
|
| 330 | 330 | public function getPasswordResetToken() |
| 331 | 331 | { |
| 332 | 332 | return $this->passwordResetToken; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @ORM\Table(name="SecurityUser") |
| 20 | 20 | * @ORM\Entity(repositoryClass="Webcook\Cms\SecurityBundle\Entity\UserRepository") |
| 21 | 21 | */ |
| 22 | -class User extends BasicEntity implements UserInterface,\Serializable |
|
| 22 | +class User extends BasicEntity implements UserInterface, \Serializable |
|
| 23 | 23 | { |
| 24 | 24 | /** |
| 25 | 25 | * Username of the user. |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | public function getSettingsByName($name) |
| 317 | 317 | { |
| 318 | 318 | foreach ($this->getSettings() as &$value) { |
| 319 | - if($value->getName() == $name) { |
|
| 319 | + if ($value->getName() == $name) { |
|
| 320 | 320 | return $value; |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -31,13 +31,13 @@ |
||
| 31 | 31 | $builder |
| 32 | 32 | ->add('name', TextType::class, array( |
| 33 | 33 | 'constraints' => array( |
| 34 | - new NotBlank(array( 'message' => 'security.roles.form.name.required')), |
|
| 34 | + new NotBlank(array('message' => 'security.roles.form.name.required')), |
|
| 35 | 35 | ), |
| 36 | 36 | 'label' => 'security.roles.form.name', |
| 37 | 37 | )) |
| 38 | 38 | ->add('role', TextType::class, array( |
| 39 | 39 | 'constraints' => array( |
| 40 | - new NotBlank(array( 'message' => 'security.roles.form.rolename.required')), |
|
| 40 | + new NotBlank(array('message' => 'security.roles.form.rolename.required')), |
|
| 41 | 41 | ), |
| 42 | 42 | 'label' => 'security.roles.form.role', |
| 43 | 43 | ))->add('version', HiddenType::class, array('mapped' => false)); |
@@ -31,25 +31,25 @@ |
||
| 31 | 31 | $builder |
| 32 | 32 | ->add('name', TextType::class, array( |
| 33 | 33 | 'constraints' => array( |
| 34 | - new NotBlank(array( 'message' => 'security.setting.form.name.required')), |
|
| 34 | + new NotBlank(array('message' => 'security.setting.form.name.required')), |
|
| 35 | 35 | ), |
| 36 | 36 | 'label' => 'security.settings.form.name', |
| 37 | 37 | )) |
| 38 | 38 | ->add('key', TextType::class, array( |
| 39 | 39 | 'constraints' => array( |
| 40 | - new NotBlank(array( 'message' => 'security.setting.form.key.required')), |
|
| 40 | + new NotBlank(array('message' => 'security.setting.form.key.required')), |
|
| 41 | 41 | ), |
| 42 | 42 | 'label' => 'security.settings.form.email', |
| 43 | 43 | )) |
| 44 | 44 | ->add('value', TextType::class, array( |
| 45 | 45 | 'constraints' => array( |
| 46 | - new NotBlank(array( 'message' => 'security.setting.form.name.required')), |
|
| 46 | + new NotBlank(array('message' => 'security.setting.form.name.required')), |
|
| 47 | 47 | ), |
| 48 | 48 | 'label' => 'security.settings.form.password', |
| 49 | 49 | )) |
| 50 | 50 | ->add('section', TextType::class, array( |
| 51 | 51 | 'constraints' => array( |
| 52 | - new NotBlank(array( 'message' => 'security.setting.form.name.required')), |
|
| 52 | + new NotBlank(array('message' => 'security.setting.form.name.required')), |
|
| 53 | 53 | ), |
| 54 | 54 | 'label' => 'security.settings.form.section', |
| 55 | 55 | )); |
@@ -37,13 +37,13 @@ |
||
| 37 | 37 | $builder |
| 38 | 38 | ->add('username', TextType::class, array( |
| 39 | 39 | 'constraints' => array( |
| 40 | - new NotBlank(array( 'message' => 'security.user.form.name.required')), |
|
| 40 | + new NotBlank(array('message' => 'security.user.form.name.required')), |
|
| 41 | 41 | ), |
| 42 | 42 | 'label' => 'security.users.form.username', |
| 43 | 43 | )) |
| 44 | 44 | ->add('email', EmailType::class, array( |
| 45 | 45 | 'constraints' => array( |
| 46 | - new Email(array( 'message' => 'security.user.form.name.not_valid')), |
|
| 46 | + new Email(array('message' => 'security.user.form.name.not_valid')), |
|
| 47 | 47 | ), |
| 48 | 48 | 'label' => 'security.users.form.email', |
| 49 | 49 | )) |