]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Disabled delete button for the logged user 2327/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 2 Oct 2016 11:21:45 +0000 (13:21 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 2 Oct 2016 11:29:57 +0000 (13:29 +0200)
To avoid some bad things to happen…

src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig
tests/Wallabag/UserBundle/Controller/ManageControllerTest.php

index 5292ba78de95e4975718dba184e5b4e4a49144cf..d5cf99c32691338365b4c004a44178fb7fe549d9 100644 (file)
@@ -72,7 +72,7 @@
                             </form>
                             <p>
                                 {{ form_start(delete_form) }}
-                                    <button onclick="return confirm('{{ 'user.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'user.form.delete'|trans }}</button>
+                                    <button {% if app.user.id == user.id %}disabled="disabled"{% endif %} onclick="return confirm('{{ 'user.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'user.form.delete'|trans }}</button>
                                 {{ form_end(delete_form) }}
                             </p>
                             <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('user_index') }}">{{ 'user.form.back_to_list'|trans }}</a></p>
index 247eb6ba9c20be239a43d380f09d10135afbf614..19b824b87bc0eddf7794833609b3b582c96d7b43 100644 (file)
@@ -68,4 +68,15 @@ class ManageControllerTest extends WallabagCoreTestCase
         // Check the user has been delete on the list
         $this->assertNotRegExp('/Foo User/', $client->getResponse()->getContent());
     }
+
+    public function testDeleteDisabledForLoggedUser()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/users/'.$this->getLoggedInUserId().'/edit');
+        $disabled = $crawler->selectButton('user.form.delete')->extract('disabled');
+
+        $this->assertEquals('disabled', $disabled[0]);
+    }
 }