From 152fcccd4489378a8ed9391e3e191df4aeba6435 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 30 Sep 2016 20:09:06 +0200 Subject: [PATCH] Add users management UI MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - remove the “add a user” from the config page - add a CRUD on user - fix some missing translations (+ bad indentation) --- app/config/routing.yml | 5 + app/config/security.yml | 1 + .../Controller/ConfigController.php | 27 ---- .../Resources/translations/messages.da.yml | 36 ++++- .../Resources/translations/messages.de.yml | 36 ++++- .../Resources/translations/messages.en.yml | 40 ++++- .../Resources/translations/messages.es.yml | 36 ++++- .../Resources/translations/messages.fa.yml | 36 ++++- .../Resources/translations/messages.fr.yml | 34 +++- .../Resources/translations/messages.it.yml | 37 ++++- .../Resources/translations/messages.oc.yml | 34 +++- .../Resources/translations/messages.pl.yml | 88 +++++++---- .../Resources/translations/messages.ro.yml | 36 ++++- .../Resources/translations/messages.tr.yml | 36 ++++- .../Resources/translations/validators.da.yml | 6 +- .../Resources/translations/validators.tr.yml | 10 +- .../CoreBundle/Resources/views/base.html.twig | 2 +- .../views/themes/baggy/Config/index.html.twig | 42 ----- .../themes/material/Config/index.html.twig | 52 +----- .../views/themes/material/layout.html.twig | 6 +- .../Controller/ManageController.php | 149 ++++++++++++++++++ src/Wallabag/UserBundle/Entity/User.php | 2 +- src/Wallabag/UserBundle/Form/NewUserType.php | 58 +++++++ src/Wallabag/UserBundle/Form/UserType.php | 61 +++++++ .../Resources/views/Manage/edit.html.twig | 86 ++++++++++ .../Resources/views/Manage/index.html.twig | 48 ++++++ .../Resources/views/Manage/new.html.twig | 61 +++++++ .../Resources/views/manage.html.twig | 43 +++++ .../Controller/ManageControllerTest.php | 71 +++++++++ 29 files changed, 956 insertions(+), 223 deletions(-) create mode 100644 src/Wallabag/UserBundle/Controller/ManageController.php create mode 100644 src/Wallabag/UserBundle/Form/NewUserType.php create mode 100644 src/Wallabag/UserBundle/Form/UserType.php create mode 100644 src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig create mode 100644 src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig create mode 100644 src/Wallabag/UserBundle/Resources/views/Manage/new.html.twig create mode 100644 src/Wallabag/UserBundle/Resources/views/manage.html.twig create mode 100644 tests/Wallabag/UserBundle/Controller/ManageControllerTest.php diff --git a/app/config/routing.yml b/app/config/routing.yml index 40cc7165..2be74d7f 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -7,6 +7,11 @@ wallabag_import: type: annotation prefix: /import +wallabag_user: + resource: "@WallabagUserBundle/Controller/" + type: annotation + prefix: /users + wallabag_api: resource: "@WallabagApiBundle/Resources/config/routing.yml" prefix: / diff --git a/app/config/security.yml b/app/config/security.yml index 1f30e58b..efb00a53 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -63,4 +63,5 @@ security: - { path: ^/share, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/settings, roles: ROLE_SUPER_ADMIN } - { path: ^/annotations, roles: ROLE_USER } + - { path: ^/users, roles: ROLE_SUPER_ADMIN } - { path: ^/, roles: ROLE_USER } diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index f1e212d9..51d8bdd1 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -13,7 +13,6 @@ use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\TaggingRule; use Wallabag\CoreBundle\Form\Type\ConfigType; use Wallabag\CoreBundle\Form\Type\ChangePasswordType; -use Wallabag\CoreBundle\Form\Type\NewUserType; use Wallabag\CoreBundle\Form\Type\RssType; use Wallabag\CoreBundle\Form\Type\TaggingRuleType; use Wallabag\CoreBundle\Form\Type\UserInformationType; @@ -138,38 +137,12 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config').'#set5'); } - // handle adding new user - $newUser = $userManager->createUser(); - // enable created user by default - $newUser->setEnabled(true); - $newUserForm = $this->createForm(NewUserType::class, $newUser, [ - 'validation_groups' => ['Profile'], - 'action' => $this->generateUrl('config').'#set6', - ]); - $newUserForm->handleRequest($request); - - if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { - $userManager->updateUser($newUser); - - // dispatch a created event so the associated config will be created - $event = new UserEvent($newUser, $request); - $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); - - $this->get('session')->getFlashBag()->add( - 'notice', - $this->get('translator')->trans('flashes.config.notice.user_added', ['%username%' => $newUser->getUsername()]) - ); - - return $this->redirect($this->generateUrl('config').'#set6'); - } - return $this->render('WallabagCoreBundle:Config:index.html.twig', [ 'form' => [ 'config' => $configForm->createView(), 'rss' => $rssForm->createView(), 'pwd' => $pwdForm->createView(), 'user' => $userForm->createView(), - 'new_user' => $newUserForm->createView(), 'new_tagging_rule' => $newTaggingRule->createView(), ], 'rss' => [ diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index da7e2652..40644ff5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -31,6 +31,7 @@ menu: search: 'Søg' # save_link: 'Save a link' back_to_unread: 'Tilbage til de ulæste artikler' + # users_management: 'Users management' top: add_new_entry: 'Tilføj ny artikel' search: 'Søg' @@ -129,12 +130,6 @@ config: # or: 'One rule OR another' # and: 'One rule AND another' # matches: 'Tests that a subject is matches a search (case-insensitive).
Example: title matches "football"' - form_new_user: - username_label: 'Brugernavn' - password_label: 'Adgangskode' - repeat_new_password_label: 'Gentag adgangskode' - plain_password_label: '????' - email_label: 'Emailadresse' entry: page_titles: @@ -396,12 +391,14 @@ developer: # page_title: 'Developer > New client' # page_description: 'You are about to create a new client. Please fill the field below for the redirect URI of your application.' # form: + # name_label: 'Name of the client' # redirect_uris_label: 'Redirect URIs' # save_label: 'Create a new client' # action_back: 'Back' # client_parameter: # page_title: 'Developer > Client parameters' # page_description: 'Here are your client parameters.' + # field_name: 'Client name' # field_id: 'Client ID' # field_secret: 'Client secret' # back: 'Back' @@ -419,6 +416,33 @@ developer: # paragraph_8: 'If you want to see all the API endpoints, you can have a look to our API documentation.' # back: 'Back' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Brugernavn' + # name_label: 'Name' + password_label: 'Adgangskode' + repeat_new_password_label: 'Gentag adgangskode' + plain_password_label: '????' + email_label: 'Emailadresse' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index eb82f13f..6f790744 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -31,6 +31,7 @@ menu: search: 'Suche' save_link: 'Link speichern' back_to_unread: 'Zurück zu ungelesenen Artikeln' + # users_management: 'Users management' top: add_new_entry: 'Neuen Artikel hinzufügen' search: 'Suche' @@ -129,12 +130,6 @@ config: or: 'Eine Regel ODER die andere' and: 'Eine Regel UND eine andere' matches: 'Tests, ob eine Variable auf eine Suche zutrifft (Groß- und Kleinschreibung wird nicht berücksichtigt).
Beispiel: title matches "Fußball"' - form_new_user: - username_label: 'Benutzername' - password_label: 'Kennwort' - repeat_new_password_label: 'Neues Kennwort wiederholen' - plain_password_label: '????' - email_label: 'E-Mail-Adresse' entry: page_titles: @@ -396,12 +391,14 @@ developer: page_title: 'Entwickler > Neuer Client' page_description: 'Du bist dabei, einen neuen Client zu erstellen. Fülle das nachfolgende Feld für die Weiterleitungs-URIs deiner Anwendung aus.' form: + # name_label: 'Name of the client' redirect_uris_label: 'Weiterleitungs-URIs' save_label: 'Neuen Client erstellen' action_back: 'Zurück' client_parameter: page_title: 'Entwickler > Client-Parameter' page_description: 'Dies sind deine Client-Parameter.' + # field_name: 'Client name' field_id: 'Client-ID' field_secret: 'Client-Secret' back: 'Zurück' @@ -419,6 +416,33 @@ developer: paragraph_8: 'Wenn du alle API-Endpunkte sehen willst, werfe einen Blick auf die API-Dokumentation.' back: 'Zurück' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Benutzername' + # name_label: 'Name' + password_label: 'Kennwort' + repeat_new_password_label: 'Neues Kennwort wiederholen' + plain_password_label: '????' + email_label: 'E-Mail-Adresse' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 01d8053b..91abe162 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -31,6 +31,7 @@ menu: search: 'Search' save_link: 'Save a link' back_to_unread: 'Back to unread articles' + users_management: 'Users management' top: add_new_entry: 'Add a new entry' search: 'Search' @@ -129,12 +130,6 @@ config: or: 'One rule OR another' and: 'One rule AND another' matches: 'Tests that a subject is matches a search (case-insensitive).
Example: title matches "football"' - form_new_user: - username_label: 'Username' - password_label: 'Password' - repeat_new_password_label: 'Repeat new password' - plain_password_label: '????' - email_label: 'Email' entry: page_titles: @@ -421,6 +416,33 @@ developer: paragraph_8: 'If you want to see all the API endpoints, you can have a look to our API documentation.' back: 'Back' +user: + page_title: Users management + new_user: Create a new user + edit_user: Edit an existing user + description: "Here you can manage all users (create, edit and delete)" + list: + actions: Actions + edit_action: Edit + yes: Yes + no: No + create_new_one: Create a new user + form: + username_label: 'Username' + name_label: 'Name' + password_label: 'Password' + repeat_new_password_label: 'Repeat new password' + plain_password_label: '????' + email_label: 'Email' + enabled_label: 'Enabled' + locked_label: 'Locked' + last_login_label: 'Last login' + twofactor_label: Two factor authentication + save: Save + delete: Delete + delete_confirm: Are you sure? + back_to_list: Back to list + flashes: config: notice: @@ -431,7 +453,6 @@ flashes: rss_updated: 'RSS information updated' tagging_rules_updated: 'Tagging rules updated' tagging_rules_deleted: 'Tagging rule deleted' - user_added: 'User "%username%" added' rss_token_updated: 'RSS token updated' entry: notice: @@ -462,3 +483,8 @@ flashes: notice: client_created: 'New client %name% created.' client_deleted: 'Client %name% deleted' + user: + notice: + added: 'User "%username%" added' + updated: 'User "%username%" updated' + deleted: 'User "%username%" deleted' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 5364e99a..25d2f3a2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -31,6 +31,7 @@ menu: search: 'Buscar' save_link: 'Archivar un enlace' back_to_unread: 'Volver a los artículos sin leer' + # users_management: 'Users management' top: add_new_entry: 'Añadir un nuevo artículo' search: 'Buscar' @@ -129,12 +130,6 @@ config: or: 'Una regla U otra' and: 'Una regla Y la otra' matches: 'Pruebe si un sujeto corresponde a una búsqueda (insensible a mayusculas).
Ejemplo : título coincide "football"' - form_new_user: - username_label: 'Nombre de usuario' - password_label: 'Contraseña' - repeat_new_password_label: 'Confirmar la nueva contraseña' - plain_password_label: '????' - email_label: 'Email' entry: page_titles: @@ -396,12 +391,14 @@ developer: page_title: 'Promotor > Nuevo cliente' page_description: 'Va a crear un nuevo cliente. Por favor, llene el campo abajo para URI redirigido de su aplicación.' form: + # name_label: 'Name of the client' redirect_uris_label: 'los URI redirigidos' save_label: 'Crear un nuevo cliente' action_back: 'Atrás' client_parameter: page_title: 'Promotor > Parámetros del cliente' page_description: 'Aquí hay sus parámetros del cliente.' + # field_name: 'Client name' field_id: 'Identificación del cliente' field_secret: 'Cliente secreto' back: 'Atrás' @@ -419,6 +416,33 @@ developer: paragraph_8: 'Si quiere ver todos los fines de API, se puede ver a nuestra documentación API.' back: 'Atrás' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Nombre de usuario' + # name_label: 'Name' + password_label: 'Contraseña' + repeat_new_password_label: 'Confirmar la nueva contraseña' + plain_password_label: '????' + email_label: 'Email' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 6f42b173..b02ffea0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -31,6 +31,7 @@ menu: search: 'جستجو' save_link: 'ذخیرهٔ یک پیوند' back_to_unread: 'بازگشت به خوانده‌نشده‌ها' + # users_management: 'Users management' top: add_new_entry: 'افزودن مقالهٔ تازه' search: 'جستجو' @@ -129,12 +130,6 @@ config: # or: 'One rule OR another' # and: 'One rule AND another' # matches: 'Tests that a subject is matches a search (case-insensitive).
Example: title matches "football"' - form_new_user: - username_label: 'نام کاربری' - password_label: 'رمز' - repeat_new_password_label: 'رمز تازه را دوباره بنویسید' - plain_password_label: '????' - email_label: 'نشانی ایمیل' entry: page_titles: @@ -395,12 +390,14 @@ developer: # page_title: 'Developer > New client' # page_description: 'You are about to create a new client. Please fill the field below for the redirect URI of your application.' # form: + # name_label: 'Name of the client' # redirect_uris_label: 'Redirect URIs' # save_label: 'Create a new client' # action_back: 'بازگشت' # client_parameter: # page_title: 'Developer > Client parameters' # page_description: 'Here are your client parameters.' + # field_name: 'Client name' # field_id: 'Client ID' # field_secret: 'Client secret' # back: 'بازگشت' @@ -418,6 +415,33 @@ developer: # paragraph_8: 'If you want to see all the API endpoints, you can have a look to our API documentation.' # back: 'بازگشت' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'نام کاربری' + # name_label: 'Name' + password_label: 'رمز' + repeat_new_password_label: 'رمز تازه را دوباره بنویسید' + plain_password_label: '????' + email_label: 'نشانی ایمیل' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 6984be83..598205b0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -31,6 +31,7 @@ menu: search: 'Recherche' save_link: 'Sauvegarder un nouvel article' back_to_unread: 'Retour aux articles non lus' + users_management: 'Gestion des utilisateurs' top: add_new_entry: 'Sauvegarder un nouvel article' search: 'Rechercher' @@ -129,12 +130,6 @@ config: or: "Une règle OU l'autre" and: "Une règle ET l'autre" matches: 'Teste si un sujet correspond à une recherche (non sensible à la casse).
Exemple : title matches "football"' - form_new_user: - username_label: "Nom d'utilisateur" - password_label: 'Mot de passe' - repeat_new_password_label: 'Confirmez votre nouveau mot de passe' - plain_password_label: 'Mot de passe en clair' - email_label: 'Adresse e-mail' entry: page_titles: @@ -421,6 +416,33 @@ developer: paragraph_8: "Si vous voulez toutes les méthodes de l'API, jetez un oeil à la documentation de l'API." back: 'Retour' +user: + page_title: Gestion des utilisateurs + new_user: Créer un nouvel utilisateur + edit_user: Éditer un utilisateur existant + description: Ici vous pouvez gérer vos utilisateurs (création, mise à jour et suppression) + list: + actions: Actions + edit_action: Éditer + yes: Oui + no: Non + create_new_one: Créer un nouvel utilisateur + form: + username_label: "Nom d'utilisateur" + name_label: 'Nom' + password_label: 'Mot de passe' + repeat_new_password_label: 'Confirmez votre nouveau mot de passe' + plain_password_label: 'Mot de passe en clair' + email_label: 'Adresse e-mail' + enabled_label: 'Activé' + locked_label: 'Bloqué' + last_login_label: 'Dernière connexion' + twofactor_label: Double authentification + save: Sauvegarder + delete: Supprimer + delete_confirm: Êtes-vous sûr? + back_to_list: Revenir à la liste + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 30b3287e..c58c929f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -31,6 +31,7 @@ menu: search: 'Cerca' save_link: 'Salva collegamento' back_to_unread: 'Torna ai contenuti non letti' + # users_management: 'Users management' top: add_new_entry: 'Aggiungi un nuovo contenuto' search: 'Cerca' @@ -129,12 +130,6 @@ config: or: "Una regola O un'altra" and: "Una regola E un'altra" matches: 'Verifica che un oggetto risulti in una ricerca (case-insensitive).
Esempio: titolo contiene "football"' - form_new_user: - username_label: 'Username' - password_label: 'Password' - repeat_new_password_label: 'Ripeti password' - plain_password_label: '????' - email_label: 'E-mail' entry: page_titles: @@ -162,6 +157,7 @@ entry: status_label: 'Stato' archived_label: 'Archiviati' starred_label: 'Preferiti' + # unread_label: 'Unread' preview_picture_label: "Ha un'immagine di anteprima" preview_picture_help: 'Immagine di anteprima' language_label: 'Lingua' @@ -395,12 +391,14 @@ developer: page_title: 'Sviluppatori > Nuovo client' page_description: 'Stai per creare un nuovo client. Compila i campi sottostanti per il redirect URI della tua applicazione.' form: + # name_label: 'Name of the client' redirect_uris_label: 'Redirect URI' save_label: 'Crea un nuovo client' action_back: 'Indietro' client_parameter: page_title: 'Sviluppatori > parametri Client' page_description: 'Questi sono i tuoi parametri del client.' + # field_name: 'Client name' field_id: 'Client ID' field_secret: 'Client secret' back: 'Indietro' @@ -418,6 +416,33 @@ developer: paragraph_8: 'Se vuoi visualizzare tutti gli API endpoints, dai una occhiata alla documentazione delle API.' back: 'Indietro' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Username' + # name_label: 'Name' + password_label: 'Password' + repeat_new_password_label: 'Ripeti password' + plain_password_label: '????' + email_label: 'E-mail' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index a077f1bf..8f06434d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -31,6 +31,7 @@ menu: search: 'Cercar' save_link: 'Enregistrar un novèl article' back_to_unread: 'Tornar als articles pas legits' + # users_management: 'Users management' top: add_new_entry: 'Enregistrar un novèl article' search: 'Cercar' @@ -129,12 +130,6 @@ config: or: "Una règla O l'autra" and: "Una règla E l'autra" matches: 'Teste se un subjècte correspond a una recerca (non sensibla a la cassa).
Exemple : title matches \"football\"' - form_new_user: - username_label: "Nom d'utilizaire" - password_label: 'Senhal' - repeat_new_password_label: 'Confirmatz vòstre novèl senhal' - plain_password_label: 'Senhal en clar' - email_label: 'Adreça de corrièl' entry: page_titles: @@ -421,6 +416,33 @@ developer: paragraph_8: "Se volètz totas las adreças d'accès de l'API, donatz un còp d’uèlh a la documentacion de l'API." back: 'Retorn' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: "Nom d'utilizaire" + # name_label: 'Name' + password_label: 'Senhal' + repeat_new_password_label: 'Confirmatz vòstre novèl senhal' + plain_password_label: 'Senhal en clar' + email_label: 'Adreça de corrièl' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index cad94dd5..54e669b3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -31,6 +31,7 @@ menu: search: 'Szukaj' save_link: 'Zapisz link' back_to_unread: 'Powrót do nieprzeczytanych artykułów' + # users_management: 'Users management' top: add_new_entry: 'Dodaj nowy wpis' search: 'Szukaj' @@ -129,12 +130,6 @@ config: or: 'Jedna reguła LUB inna' and: 'Jedna reguła I inna' matches: 'Sprawdź czy temat pasuje szukaj (duże lub małe litery).
Przykład: tytuł zawiera "piłka nożna"' - form_new_user: - username_label: 'Nazwa użytkownika' - password_label: 'Hasło' - repeat_new_password_label: 'Powtórz nowe hasło' - plain_password_label: 'Jawne hasło' - email_label: 'Adres email' entry: page_titles: @@ -379,36 +374,38 @@ developer: full_documentation: 'Pokaż pełne API' list_methods: 'Lista metod API' clients: - title: 'Klienci' - create_new: 'Utwórz nowego klienta' + title: 'Klienci' + create_new: 'Utwórz nowego klienta' existing_clients: - title: 'Istniejący klienci' - field_id: 'ID klienta' - field_secret: 'Client secret' - field_uris: 'Przekieruj URIs' - field_grant_types: 'Przyznaj pozwolenie' - no_client: 'Nie ma jeszcze klienta.' + title: 'Istniejący klienci' + field_id: 'ID klienta' + field_secret: 'Client secret' + field_uris: 'Przekieruj URIs' + field_grant_types: 'Przyznaj pozwolenie' + no_client: 'Nie ma jeszcze klienta.' remove: - warn_message_1: 'Masz możliwość usunięcia tego klienta. Ta akcja jest NIEODWRACALNA !' - warn_message_2: "Jeżeli go usuniesz, aplikacje skonfigurowane z tym klientem nię będa w stanie autoryzować twojego wallabag." - action: 'Usuń tego klienta' + warn_message_1: 'Masz możliwość usunięcia tego klienta. Ta akcja jest NIEODWRACALNA !' + warn_message_2: "Jeżeli go usuniesz, aplikacje skonfigurowane z tym klientem nię będa w stanie autoryzować twojego wallabag." + action: 'Usuń tego klienta' client: - page_title: 'Deweloper > Nowy klient' - page_description: 'Tworzysz nowego klienta. Wypełnij poniższe pole w celu przekierowania URI twojej aplikacji.' - form: - redirect_uris_label: 'Przekieruj adresy URI' - save_label: 'Stwórz nowego klienta' - action_back: 'Cofnij' + page_title: 'Deweloper > Nowy klient' + page_description: 'Tworzysz nowego klienta. Wypełnij poniższe pole w celu przekierowania URI twojej aplikacji.' + form: + # name_label: 'Name of the client' + redirect_uris_label: 'Przekieruj adresy URI' + save_label: 'Stwórz nowego klienta' + action_back: 'Cofnij' client_parameter: - page_title: 'Deweloper > Parametry klienta' - page_description: 'Tutaj znajdują się parametry klienta.' - field_id: 'Client ID' - field_secret: 'Client secret' - back: 'Cofnij' - read_howto: 'Przeczytaj jak "Stworzyć moją pierwszą aplikację"' + page_title: 'Deweloper > Parametry klienta' + page_description: 'Tutaj znajdują się parametry klienta.' + # field_name: 'Client name' + field_id: 'Client ID' + field_secret: 'Client secret' + back: 'Cofnij' + read_howto: 'Przeczytaj jak "Stworzyć moją pierwszą aplikację"' howto: - page_title: 'Deweloper > Jak stworzyć moją pierwszą aplikację' - description: + page_title: 'Deweloper > Jak stworzyć moją pierwszą aplikację' + description: paragraph_1: 'Następujące komendy korzystają Biblioteka HTTPie. Upewnij się, czy zainstalowałeś ją w swoim systemie zanim z niej skorzystasz' paragraph_2: 'Potrzebujesz tokena w celu nawiązania komunikacji między swoją aplikacją a API wallabag.' paragraph_3: 'W celu stworzenia tokena musisz stwórz nowego klienta.' @@ -417,7 +414,34 @@ developer: paragraph_6: 'access_token jest użyteczny do wywołania API endpoint. Na przykład:' paragraph_7: 'To wywołanie zwróci wszystkie twoje wpisy.' paragraph_8: 'Jeżeli chcesz wyświetlić wszystkie punkty końcowe API, zobacz Dokumentacja naszego API.' - back: 'Cofnij' + back: 'Cofnij' + +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Nazwa użytkownika' + # name_label: 'Name' + password_label: 'Hasło' + repeat_new_password_label: 'Powtórz nowe hasło' + plain_password_label: 'Jawne hasło' + email_label: 'Adres email' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list flashes: config: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index a271d6f3..4e0e454c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -31,6 +31,7 @@ menu: search: 'Căutare' # save_link: 'Save a link' back_to_unread: 'Înapoi la articolele necitite' + # users_management: 'Users management' top: add_new_entry: 'Introdu un nou articol' search: 'Căutare' @@ -129,12 +130,6 @@ config: # or: 'One rule OR another' # and: 'One rule AND another' # matches: 'Tests that a subject is matches a search (case-insensitive).
Example: title matches "football"' - form_new_user: - username_label: 'Nume de utilizator' - password_label: 'Parolă' - repeat_new_password_label: 'Repeat new password' - plain_password_label: '????' - email_label: 'E-mail' entry: page_titles: @@ -396,12 +391,14 @@ developer: # page_title: 'Developer > New client' # page_description: 'You are about to create a new client. Please fill the field below for the redirect URI of your application.' # form: + # name_label: 'Name of the client' # redirect_uris_label: 'Redirect URIs' # save_label: 'Create a new client' # action_back: 'Back' # client_parameter: # page_title: 'Developer > Client parameters' # page_description: 'Here are your client parameters.' + # field_name: 'Client name' # field_id: 'Client ID' # field_secret: 'Client secret' # back: 'Back' @@ -419,6 +416,33 @@ developer: # paragraph_8: 'If you want to see all the API endpoints, you can have a look to our API documentation.' # back: 'Back' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Nume de utilizator' + # name_label: 'Name' + password_label: 'Parolă' + repeat_new_password_label: 'Repeat new password' + plain_password_label: '????' + email_label: 'E-mail' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index f2307e65..02b3aae6 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -31,6 +31,7 @@ menu: search: 'Ara' # save_link: 'Save a link' back_to_unread: 'Okunmayan makalelere geri dön' + # users_management: 'Users management' top: add_new_entry: 'Yeni bir makale ekle' search: 'Ara' @@ -128,12 +129,6 @@ config: or: 'Bir kural veya birbaşkası' and: 'Bir kural ve diğeri' # matches: 'Tests that a subject is matches a search (case-insensitive).
Example: title matches "football"' - form_new_user: - username_label: 'Kullanıcı adı' - password_label: 'Şifre' - repeat_new_password_label: 'Yeni şifrenin tekrarı' - plain_password_label: '????' - email_label: 'E-posta' entry: page_titles: @@ -395,12 +390,14 @@ developer: # page_title: 'Developer > New client' # page_description: 'You are about to create a new client. Please fill the field below for the redirect URI of your application.' # form: + # name_label: 'Name of the client' # redirect_uris_label: 'Redirect URIs' # save_label: 'Create a new client' # action_back: 'Back' # client_parameter: # page_title: 'Developer > Client parameters' # page_description: 'Here are your client parameters.' + # field_name: 'Client name' # field_id: 'Client ID' # field_secret: 'Client secret' # back: 'Back' @@ -418,6 +415,33 @@ developer: # paragraph_8: 'If you want to see all the API endpoints, you can have a look to our API documentation.' # back: 'Back' +user: + # page_title: Users management + # new_user: Create a new user + # edit_user: Edit an existing user + # description: "Here you can manage all users (create, edit and delete)" + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new user + form: + username_label: 'Kullanıcı adı' + # name_label: 'Name' + password_label: 'Şifre' + repeat_new_password_label: 'Yeni şifrenin tekrarı' + plain_password_label: '????' + email_label: 'E-posta' + # enabled_label: 'Enabled' + # locked_label: 'Locked' + # last_login_label: 'Last login' + # twofactor_label: Two factor authentication + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + flashes: config: notice: diff --git a/src/Wallabag/CoreBundle/Resources/translations/validators.da.yml b/src/Wallabag/CoreBundle/Resources/translations/validators.da.yml index dfe2c64d..313339ed 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/validators.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/validators.da.yml @@ -1,6 +1,6 @@ validator: password_must_match: 'De indtastede adgangskoder skal være ens' password_too_short: 'Adgangskoden skal være mindst 8 tegn' -# password_wrong_value: 'Wrong value for your current password' -# item_per_page_too_high: 'This will certainly kill the app' -# rss_limit_too_hight: 'This will certainly kill the app' + # password_wrong_value: 'Wrong value for your current password' + # item_per_page_too_high: 'This will certainly kill the app' + # rss_limit_too_hight: 'This will certainly kill the app' diff --git a/src/Wallabag/CoreBundle/Resources/translations/validators.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/validators.tr.yml index 80ab470a..1b358965 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/validators.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/validators.tr.yml @@ -1,6 +1,6 @@ validator: -# password_must_match: 'The password fields must match.' -# password_too_short: 'Password should by at least 8 chars long' -# password_wrong_value: 'Wrong value for your current password' -# item_per_page_too_high: 'This will certainly kill the app' -# rss_limit_too_hight: 'This will certainly kill the app' + # password_must_match: 'The password fields must match.' + # password_too_short: 'Password should by at least 8 chars long' + # password_wrong_value: 'Wrong value for your current password' + # item_per_page_too_high: 'This will certainly kill the app' + # rss_limit_too_hight: 'This will certainly kill the app' diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index 0f88901a..a1a9a136 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -43,7 +43,7 @@ {% block scripts %} {% endblock %} - wallabag - {% block title %}{% endblock %} + {% block title %}{% endblock %} – wallabag {% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index dd4f7b00..ff7ef73a 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -302,46 +302,4 @@ - - {% if is_granted('ROLE_SUPER_ADMIN') %} -

{{ 'config.tab_menu.new_user'|trans }}

- - {{ form_start(form.new_user) }} - {{ form_errors(form.new_user) }} - -
-
- {{ form_label(form.new_user.username) }} - {{ form_errors(form.new_user.username) }} - {{ form_widget(form.new_user.username) }} -
-
- -
-
- {{ form_label(form.new_user.plainPassword.first) }} - {{ form_errors(form.new_user.plainPassword.first) }} - {{ form_widget(form.new_user.plainPassword.first) }} -
-
- -
-
- {{ form_label(form.new_user.plainPassword.second) }} - {{ form_errors(form.new_user.plainPassword.second) }} - {{ form_widget(form.new_user.plainPassword.second) }} -
-
- -
-
- {{ form_label(form.new_user.email) }} - {{ form_errors(form.new_user.email) }} - {{ form_widget(form.new_user.email) }} -
-
- - {{ form_rest(form.new_user) }} - {% endif %} - {% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 650a3ae2..270c077f 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -16,9 +16,6 @@
  • {{ 'config.tab_menu.user_info'|trans }}
  • {{ 'config.tab_menu.password'|trans }}
  • {{ 'config.tab_menu.rules'|trans }}
  • - {% if is_granted('ROLE_SUPER_ADMIN') %} -
  • {{ 'config.tab_menu.new_user'|trans }}
  • - {% endif %} @@ -157,11 +154,9 @@
    {{ 'config.form_user.two_factor_description'|trans }} -
    -
    -
    -
    +
    + {{ form_widget(form.user.twoFactorAuthentication) }} {{ form_label(form.user.twoFactorAuthentication) }} {{ form_errors(form.user.twoFactorAuthentication) }} @@ -339,49 +334,6 @@
    - - {% if is_granted('ROLE_SUPER_ADMIN') %} -
    - {{ form_start(form.new_user) }} - {{ form_errors(form.new_user) }} - -
    -
    - {{ form_label(form.new_user.username) }} - {{ form_errors(form.new_user.username) }} - {{ form_widget(form.new_user.username) }} -
    -
    - -
    -
    - {{ form_label(form.new_user.plainPassword.first) }} - {{ form_errors(form.new_user.plainPassword.first) }} - {{ form_widget(form.new_user.plainPassword.first) }} -
    -
    - -
    -
    - {{ form_label(form.new_user.plainPassword.second) }} - {{ form_errors(form.new_user.plainPassword.second) }} - {{ form_widget(form.new_user.plainPassword.second) }} -
    -
    - -
    -
    - {{ form_label(form.new_user.email) }} - {{ form_errors(form.new_user.email) }} - {{ form_widget(form.new_user.email) }} -
    -
    - - {{ form_widget(form.new_user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} - {{ form_rest(form.new_user) }} - -
    - {% endif %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index b2d77c2e..c7d6d70d 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -45,7 +45,7 @@
  • {{ 'menu.left.archive'|trans }} {{ count_entries('archive') }}
  • -
  • +
  • {{ 'menu.left.all_articles'|trans }} {{ count_entries('all') }}
  • @@ -55,6 +55,10 @@ {{ 'menu.left.config'|trans }}
  • {% if is_granted('ROLE_SUPER_ADMIN') %} +
  • + {{ 'menu.left.users_management'|trans }} +
  • +
  • {{ 'menu.left.internal_settings'|trans }}
  • diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php new file mode 100644 index 00000000..92ee2b41 --- /dev/null +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -0,0 +1,149 @@ +getDoctrine()->getManager(); + + $users = $em->getRepository('WallabagUserBundle:User')->findAll(); + + return $this->render('WallabagUserBundle:Manage:index.html.twig', array( + 'users' => $users, + )); + } + + /** + * Creates a new User entity. + * + * @Route("/new", name="user_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request) + { + $userManager = $this->container->get('fos_user.user_manager'); + + $user = $userManager->createUser(); + // enable created user by default + $user->setEnabled(true); + + $form = $this->createForm('Wallabag\UserBundle\Form\NewUserType', $user, [ + 'validation_groups' => ['Profile'], + ]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $userManager->updateUser($user); + + // dispatch a created event so the associated config will be created + $event = new UserEvent($user, $request); + $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); + + $this->get('session')->getFlashBag()->add( + 'notice', + $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()]) + ); + + return $this->redirectToRoute('user_edit', array('id' => $user->getId())); + } + + return $this->render('WallabagUserBundle:Manage:new.html.twig', array( + 'user' => $user, + 'form' => $form->createView(), + )); + } + + /** + * Displays a form to edit an existing User entity. + * + * @Route("/{id}/edit", name="user_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, User $user) + { + $deleteForm = $this->createDeleteForm($user); + $editForm = $this->createForm('Wallabag\UserBundle\Form\UserType', $user); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($user); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()]) + ); + + return $this->redirectToRoute('user_edit', array('id' => $user->getId())); + } + + return $this->render('WallabagUserBundle:Manage:edit.html.twig', array( + 'user' => $user, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + 'twofactor_auth' => $this->getParameter('twofactor_auth'), + )); + } + + /** + * Deletes a User entity. + * + * @Route("/{id}", name="user_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, User $user) + { + $form = $this->createDeleteForm($user); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->get('session')->getFlashBag()->add( + 'notice', + $this->get('translator')->trans('flashes.user.notice.deleted', ['%username%' => $user->getUsername()]) + ); + + $em = $this->getDoctrine()->getManager(); + $em->remove($user); + $em->flush(); + } + + return $this->redirectToRoute('user_index'); + } + + /** + * Creates a form to delete a User entity. + * + * @param User $user The User entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(User $user) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('user_delete', array('id' => $user->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index dfed8e47..d98ae76a 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -64,7 +64,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf protected $entries; /** - * @ORM\OneToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", mappedBy="user") + * @ORM\OneToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", mappedBy="user", cascade={"remove"}) */ protected $config; diff --git a/src/Wallabag/UserBundle/Form/NewUserType.php b/src/Wallabag/UserBundle/Form/NewUserType.php new file mode 100644 index 00000000..ad5a2405 --- /dev/null +++ b/src/Wallabag/UserBundle/Form/NewUserType.php @@ -0,0 +1,58 @@ +add('username', TextType::class, [ + 'required' => true, + 'label' => 'user.form.username_label', + ]) + ->add('plainPassword', RepeatedType::class, [ + 'type' => PasswordType::class, + 'invalid_message' => 'validator.password_must_match', + 'first_options' => ['label' => 'user.form.password_label'], + 'second_options' => ['label' => 'user.form.repeat_new_password_label'], + 'constraints' => [ + new Constraints\Length([ + 'min' => 8, + 'minMessage' => 'validator.password_too_short', + ]), + new Constraints\NotBlank(), + ], + 'label' => 'user.form.plain_password_label', + ]) + ->add('email', EmailType::class, [ + 'label' => 'user.form.email_label', + ]) + ->add('save', SubmitType::class, [ + 'label' => 'user.form.save', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => 'Wallabag\UserBundle\Entity\User', + ]); + } + + public function getBlockPrefix() + { + return 'new_user'; + } +} diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php new file mode 100644 index 00000000..cfa67793 --- /dev/null +++ b/src/Wallabag/UserBundle/Form/UserType.php @@ -0,0 +1,61 @@ +add('name', TextType::class, [ + 'required' => false, + 'label' => 'user.form.name_label', + ]) + ->add('username', TextType::class, [ + 'required' => true, + 'label' => 'user.form.username_label', + ]) + ->add('email', EmailType::class, [ + 'required' => true, + 'label' => 'user.form.email_label', + ]) + ->add('enabled', CheckboxType::class, [ + 'required' => false, + 'label' => 'user.form.enabled_label', + ]) + ->add('locked', CheckboxType::class, [ + 'required' => false, + 'label' => 'user.form.locked_label', + ]) + ->add('twoFactorAuthentication', CheckboxType::class, [ + 'required' => false, + 'label' => 'user.form.twofactor_label', + ]) + ->add('save', SubmitType::class, [ + 'label' => 'user.form.save', + ]) + ; + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Wallabag\UserBundle\Entity\User', + )); + } +} diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig new file mode 100644 index 00000000..5292ba78 --- /dev/null +++ b/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig @@ -0,0 +1,86 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'user.page_title'|trans }}{% endblock %} + +{% block content %} + +
    +
    +
    +
    +
    +

    {{ 'user.edit_user'|trans }}

    + +
    + {{ form_start(edit_form) }} + {{ form_errors(edit_form) }} + +
    +
    + {{ form_label(edit_form.name) }} + {{ form_errors(edit_form.name) }} + {{ form_widget(edit_form.name) }} +
    +
    + +
    +
    + {{ form_label(edit_form.username) }} + {{ form_errors(edit_form.username) }} + {{ form_widget(edit_form.username) }} +
    +
    + +
    +
    + {{ form_label(edit_form.email) }} + {{ form_errors(edit_form.email) }} + {{ form_widget(edit_form.email) }} +
    +
    + +
    +
    + {{ form_widget(edit_form.enabled) }} + {{ form_label(edit_form.enabled) }} + {{ form_errors(edit_form.enabled) }} +
    +
    + +
    +
    + {{ form_widget(edit_form.locked) }} + {{ form_label(edit_form.locked) }} + {{ form_errors(edit_form.locked) }} +
    +
    + + {% if twofactor_auth %} +
    +
    + {{ form_widget(edit_form.twoFactorAuthentication) }} + {{ form_label(edit_form.twoFactorAuthentication) }} + {{ form_errors(edit_form.twoFactorAuthentication) }} +
    +
    + {% endif %} + +
    + + {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} + {{ form_rest(edit_form) }} + +

    + {{ form_start(delete_form) }} + + {{ form_end(delete_form) }} +

    +

    {{ 'user.form.back_to_list'|trans }}

    +
    +
    +
    +
    +
    +
    + +{% endblock %} diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig new file mode 100644 index 00000000..996bdb1a --- /dev/null +++ b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig @@ -0,0 +1,48 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'user.page_title'|trans }}{% endblock %} + +{% block content %} + +
    +
    +
    +
    +
    +

    {{ 'user.description'|trans|raw }}

    + + + + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} + +
    {{ 'user.form.username_label'|trans }}{{ 'user.form.email_label'|trans }}{{ 'user.form.last_login_label'|trans }}{{ 'user.form.locked_label'|trans }}{{ 'user.list.actions'|trans }}
    {{ user.username }}{{ user.email }}{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %}{% if user.locked %}{{ 'user.list.yes'|trans }}{% else %}{{ 'user.list.no'|trans }}{% endif %} + {{ 'user.list.edit_action'|trans }} +
    +
    +

    + {{ 'user.list.create_new_one'|trans }} +

    +
    +
    +
    +
    +
    + +{% endblock %} diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/new.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/new.html.twig new file mode 100644 index 00000000..8c894c04 --- /dev/null +++ b/src/Wallabag/UserBundle/Resources/views/Manage/new.html.twig @@ -0,0 +1,61 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'user.page_title'|trans }}{% endblock %} + +{% block content %} + +
    +
    +
    +
    +
    +

    {{ 'user.new_user'|trans }}

    + +
    + {{ form_start(form) }} + {{ form_errors(form) }} + +
    +
    + {{ form_label(form.username) }} + {{ form_errors(form.username) }} + {{ form_widget(form.username) }} +
    +
    + +
    +
    + {{ form_label(form.plainPassword.first) }} + {{ form_errors(form.plainPassword.first) }} + {{ form_widget(form.plainPassword.first) }} +
    +
    + +
    +
    + {{ form_label(form.plainPassword.second) }} + {{ form_errors(form.plainPassword.second) }} + {{ form_widget(form.plainPassword.second) }} +
    +
    + +
    +
    + {{ form_label(form.email) }} + {{ form_errors(form.email) }} + {{ form_widget(form.email) }} +
    +
    + + {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} + {{ form_rest(form) }} + +

    {{ 'user.form.back_to_list'|trans }}

    +
    +
    +
    +
    +
    +
    + +{% endblock %} diff --git a/src/Wallabag/UserBundle/Resources/views/manage.html.twig b/src/Wallabag/UserBundle/Resources/views/manage.html.twig new file mode 100644 index 00000000..c614c55f --- /dev/null +++ b/src/Wallabag/UserBundle/Resources/views/manage.html.twig @@ -0,0 +1,43 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'user.manage.page_title'|trans }}{% endblock %} + +{% block content %} + +
    +
    +
    +
    +
    +

    {{ 'user.manage.description'|trans|raw }}

    + + + + + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} + +
    {{ 'user.manage.field.username'|trans }}{{ 'user.manage.field.email'|trans }}{{ 'user.manage.field.last_login'|trans }}{{ 'user.manage.field.locked'|trans }}{{ 'user.manage.action'|trans }}
    {{ user.username }}{{ user.email }}{{ user.lastLogin|date('d/m/Y H:i:s') }}{{ user.locked ? 'yes' : 'no' }}edit - delete
    +
    +
    +
    +
    +
    + +{% endblock %} diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php new file mode 100644 index 00000000..247eb6ba --- /dev/null +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php @@ -0,0 +1,71 @@ +getClient(); + + $client->request('GET', '/users/'); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertContains('login', $client->getResponse()->headers->get('location')); + } + + public function testCompleteScenario() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + // Create a new user in the database + $crawler = $client->request('GET', '/users/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /users/"); + $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('user.form.save')->form(array( + 'new_user[username]' => 'test_user', + 'new_user[email]' => 'test@test.io', + 'new_user[plainPassword][first]' => 'test', + 'new_user[plainPassword][second]' => 'test', + )); + + $client->submit($form); + $client->followRedirect(); + $crawler = $client->request('GET', '/users/'); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); + + // Edit the user + $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); + + $form = $crawler->selectButton('user.form.save')->form(array( + 'user[name]' => 'Foo User', + 'user[username]' => 'test_user', + 'user[email]' => 'test@test.io', + 'user[enabled]' => true, + 'user[locked]' => false, + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo User" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); + + $crawler = $client->request('GET', '/users/'); + $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); + + // Delete the user + $client->submit($crawler->selectButton('user.form.delete')->form()); + $crawler = $client->followRedirect(); + + // Check the user has been delete on the list + $this->assertNotRegExp('/Foo User/', $client->getResponse()->getContent()); + } +} -- 2.41.0