]> Raphaël G. Git Repositories - airbundle/blobdiff - Controller/UserController.php
Add 75006 weather links
[airbundle] / Controller / UserController.php
index eaec69046d85abdf55da0638fbb1f0ef582d05ca..b4f57657a6c804c4f5cc07ada6676e31d30e6939 100644 (file)
@@ -1,7 +1,7 @@
 <?php declare(strict_types=1);
 
 /*
 <?php declare(strict_types=1);
 
 /*
- * This file is part of the Rapsys UserBundle package.
+ * This file is part of the Rapsys AirBundle package.
  *
  * (c) Raphaël Gertz <symfony@rapsys.eu>
  *
  *
  * (c) Raphaël Gertz <symfony@rapsys.eu>
  *
@@ -49,15 +49,6 @@ class UserController extends DefaultController {
                        throw $this->createAccessDeniedException($this->translator->trans('Unable to access user: %mail%', ['%mail%' => $smail]));
                }
 
                        throw $this->createAccessDeniedException($this->translator->trans('Unable to access user: %mail%', ['%mail%' => $smail]));
                }
 
-               //With admin
-               if ($this->isGranted('ROLE_ADMIN')) {
-                       //With pseudonym and without slug
-                       if (!empty($pseudonym = $user->getPseudonym()) && empty($user->getSlug())) {
-                               //Preset slug
-                               $user->setSlug($slugger->slug($pseudonym));
-                       }
-               }
-
                //Create the RegisterType form and give the proper parameters
                $edit = $this->createForm($this->config['edit']['view']['edit'], $user, [
                        //Set action to register route name and context
                //Create the RegisterType form and give the proper parameters
                $edit = $this->createForm($this->config['edit']['view']['edit'], $user, [
                        //Set action to register route name and context
@@ -119,11 +110,6 @@ class UserController extends DefaultController {
 
                        //Add reset view
                        $this->config['edit']['view']['context']['reset'] = $reset->createView();
 
                        //Add reset view
                        $this->config['edit']['view']['context']['reset'] = $reset->createView();
-               //Without admin role
-               //XXX: prefer a reset on login to force user unspam action
-               } else {
-                       //Add notice
-                       $this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure'));
                }
 
                //With post method
                }
 
                //With post method
@@ -136,6 +122,15 @@ class UserController extends DefaultController {
                                //Set data
                                $data = $edit->getData();
 
                                //Set data
                                $data = $edit->getData();
 
+                               //With admin
+                               if ($this->isGranted('ROLE_ADMIN')) {
+                                       //With pseudonym and without slug
+                                       if (!empty($pseudonym = $data->getPseudonym()) && empty($data->getSlug())) {
+                                               //Set slug
+                                               $data->setSlug($slugger->slug($pseudonym));
+                                       }
+                               }
+
                                //Queue snippet save
                                $manager->persist($data);
 
                                //Queue snippet save
                                $manager->persist($data);
 
@@ -152,9 +147,14 @@ class UserController extends DefaultController {
                                //Catch double slug or mail
                                } catch (UniqueConstraintViolationException $e) {
                                        //Add error message mail already exists
                                //Catch double slug or mail
                                } catch (UniqueConstraintViolationException $e) {
                                        //Add error message mail already exists
-                                       $this->addFlash('error', $this->translator->trans('Account %mail% or with slug %slug% already exists', ['%mail%' => $data->getMail(), '%slug%' => $slug]));
+                                       $this->addFlash('error', $this->translator->trans('Account %mail% already exists', ['%mail%' => $data->getMail()]));
                                }
                        }
                                }
                        }
+               //Without admin role
+               //XXX: prefer a reset on login to force user unspam action
+               } elseif (!$this->isGranted('ROLE_ADMIN')) {
+                       //Add notice
+                       $this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure'));
                }
 
                //Render view
                }
 
                //Render view