Skip to content

Commit

Permalink
Corrected Routes and using destroy in user controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
s2j1h committed Oct 22, 2010
1 parent 6971a13 commit 69e27fe
Show file tree
Hide file tree
Showing 5 changed files with 326 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update
end
end

def delete
def destroy
@user = current_user
@user_session = UserSession.find
digested_key = hash_secretkey(params[:secretkey])
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
buttons: {
'Delete my account!': function() {
$(this).dialog('close');
url = url.slice(0,url.lastIndexOf("/")+1) + "signout";
url = url.slice(0,url.lastIndexOf("/")+1) + "users/delete";
var secretkey = $("#secretkey").val();
$('<form method="post" action="' + url + '" />')
.append('<input type="hidden" name="secretkey" value="'+secretkey+'" />')
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

map.login "login", :controller => "user_sessions", :action => "new"
map.logout "logout", :controller => "user_sessions", :action => "destroy"
map.signout "signout", :controller => "users", :action => "delete"
#map.signout "signout", :controller => "users", :action => "delete"
map.register "register", :controller => "users", :action => "new"
map.lostpassword "lostpassword", :controller => "password_resets" , :action => "new"

Expand Down
Binary file modified db/development.sqlite3
Binary file not shown.
323 changes: 323 additions & 0 deletions log/development.log
Original file line number Diff line number Diff line change
Expand Up @@ -9249,3 +9249,326 @@ Processing ApplicationController#index (for 127.0.0.1 at 2010-10-22 20:07:43) [G
Rendering template within layouts/application
Rendering application/index
Completed in 19ms (View: 17, DB: 0) | 200 OK [http://127.0.0.1/]


Processing UsersController#new (for 127.0.0.1 at 2010-10-22 20:26:51) [GET]
Parameters: {"action"=>"new", "controller"=>"users"}
Rendering template within layouts/application
Rendering users/new
Completed in 25ms (View: 10, DB: 0) | 200 OK [http://127.0.0.1/users/new]


Processing UsersController#create (for 127.0.0.1 at 2010-10-22 20:27:09) [POST]
Parameters: {"commit"=>"Submit", "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"users", "user"=>{"password_confirmation"=>"[FILTERED]", "username"=>"[FILTERED]", "secretkey_confirmation"=>"[FILTERED]", "secretkey"=>"[FILTERED]", "password"=>"[FILTERED]", "email"=>"test2@fr.fr"}}
User Load (0.1ms) SELECT "users".id FROM "users" WHERE (LOWER("users"."email") = 'test2@fr.fr') LIMIT 1
User Load (0.1ms) SELECT "users".id FROM "users" WHERE (LOWER("users"."username") = 'test2') LIMIT 1
User Load (0.1ms) SELECT "users".id FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
User Create (0.2ms) INSERT INTO "users" ("created_at", "crypted_password", "updated_at", "perishable_token", "username", "password_salt", "persistence_token", "secretkey", "email") VALUES('2010-10-22 18:27:09', '262258a69c5541f63cdf482bb70d04d514d679ca0a096825e0c314e7bcc5ea14e92b2175f0c772c14bf8057e1bc104a14c4dec52aa086c95bd870ea93cbd1b07', '2010-10-22 18:27:09', 'Hqn5NeMK0x9IwDe69mj4', 'test2', '83Y0ZGfzFlccIPYKILSH', 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193', 'f2d81a260dea8a100dd517984e53c56a7523d96942a834b9cdc249bd4e8c7aa9', 'test2@fr.fr')
Sent mail to vauban@zeneffy.fr

Date: Fri, 22 Oct 2010 20:27:09 +0200
From: vauban@zeneffy.fr
To: vauban@zeneffy.fr
Subject: [Vauban.zeneffy.fr] New user!
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>New user</h1>

<p>Dear site administrator,</p>
<p>
You're lucky today, you've got a new user!
</p>
<p>
<b>User</b>: test2<br/>
<b>User's email</b>: test2@fr.fr<br/>
<b>Registered at</b>: Fri Oct 22 20:27:09 +0200 2010
</p>

</body>
</html>
Redirected to http://127.0.0.1:3000/identities
Completed in 30ms (DB: 0) | 302 Found [http://127.0.0.1/users]


Processing IdentitiesController#index (for 127.0.0.1 at 2010-10-22 20:27:10) [GET]
Parameters: {"action"=>"index", "controller"=>"identities"}
User Load (0.3ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Identity Load (0.2ms) SELECT * FROM "identities" WHERE ("identities".user_id = 8) ORDER BY name,created_at
Rendering template within layouts/application
Rendering identities/index
Completed in 102ms (View: 5, DB: 0) | 200 OK [http://127.0.0.1/identities]


Processing UsersController#edit (for 127.0.0.1 at 2010-10-22 20:27:14) [GET]
Parameters: {"action"=>"edit", "id"=>"current", "controller"=>"users"}
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Rendering template within layouts/application
Rendering users/edit
Completed in 29ms (View: 12, DB: 0) | 200 OK [http://127.0.0.1/users/current/edit]


Processing ApplicationController#delete (for 127.0.0.1 at 2010-10-22 20:27:19) [DELETE]
Parameters: {"action"=>"delete", "_method"=>"delete", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "secretkey"=>"[FILTERED]"}

ActionController::RoutingError (No route matches "/user" with {:method=>:delete}):
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)


Processing UsersController#edit (for 127.0.0.1 at 2010-10-22 20:27:36) [GET]
Parameters: {"action"=>"edit", "id"=>"current", "controller"=>"users"}
User Load (0.3ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Rendering template within layouts/application
Rendering users/edit
Completed in 31ms (View: 13, DB: 0) | 200 OK [http://127.0.0.1/users/current/edit]


Processing UsersController#index (for 127.0.0.1 at 2010-10-22 20:27:40) [DELETE]
Parameters: {"action"=>"index", "_method"=>"delete", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"users", "secretkey"=>"[FILTERED]"}
Redirected to http://127.0.0.1:3000/
Completed in 2ms (DB: 0) | 302 Found [http://127.0.0.1/users]


Processing ApplicationController#index (for 127.0.0.1 at 2010-10-22 20:27:40) [GET]
Parameters: {"action"=>"index", "controller"=>"application"}
Rendering template within layouts/application
Rendering application/index
User Load (0.3ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Completed in 105ms (View: 102, DB: 0) | 200 OK [http://127.0.0.1/]


Processing UsersController#edit (for 127.0.0.1 at 2010-10-22 20:34:56) [GET]
Parameters: {"action"=>"edit", "id"=>"current", "controller"=>"users"}
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Rendering template within layouts/application
Rendering users/edit
Completed in 28ms (View: 12, DB: 0) | 200 OK [http://127.0.0.1/users/current/edit]


Processing UsersController#destroy (for 127.0.0.1 at 2010-10-22 20:35:00) [DELETE]
Parameters: {"action"=>"destroy", "_method"=>"delete", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "id"=>"delete", "controller"=>"users", "secretkey"=>"[FILTERED]"}

ActionController::UnknownAction (No action responded to destroy. Actions: create, delete, edit, index, new, and update):
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)


Processing ApplicationController#index (for 127.0.0.1 at 2010-10-22 20:38:07) [GET]
Parameters: {"action"=>"index", "controller"=>"application"}
Rendering template within layouts/application
Rendering application/index
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Completed in 22ms (View: 19, DB: 0) | 200 OK [http://127.0.0.1/]


Processing UsersController#edit (for 127.0.0.1 at 2010-10-22 20:38:09) [GET]
Parameters: {"action"=>"edit", "id"=>"current", "controller"=>"users"}
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Rendering template within layouts/application
Rendering users/edit
Completed in 24ms (View: 7, DB: 0) | 200 OK [http://127.0.0.1/users/current/edit]


Processing UsersController#destroy (for 127.0.0.1 at 2010-10-22 20:38:15) [DELETE]
Parameters: {"action"=>"destroy", "_method"=>"delete", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "id"=>"delete", "controller"=>"users", "secretkey"=>"[FILTERED]"}
User Load (0.3ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
CACHE (0.0ms) SELECT * FROM "users" WHERE ("users"."persistence_token" = 'f2e97e496943fe24e331ebc91c9fe37e46ecd57ab0be863c0ed2c59eadca2360ba4b6dee5819b9d2e0cf4094bbcd3e5756518e961e67ec4ae0ad08f7f80a1193') LIMIT 1
Identity Load (0.1ms) SELECT * FROM "identities" WHERE ("identities".user_id = 8) 
User Destroy (0.1ms) DELETE FROM "users" WHERE "id" = 8
Sent mail to test2@fr.fr

Date: Fri, 22 Oct 2010 20:38:15 +0200
From: vauban@zeneffy.fr
To: test2@fr.fr
Subject: Your vauban account has been successfully closed
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Your account has been deleted</h1>

<p>
A request to delete your account has been made today - We confirm you that none of your identities has been kept and this is the last mail you will received from us.
</p>
<p>
Feel free to contact us at vauban@zeneffy.fr if you have any comment or feedbacks after using Vauban
</p>

<p>
The Vauban team
</p>

</body>
</html>
Sent mail to vauban@zeneffy.fr

Date: Fri, 22 Oct 2010 20:38:15 +0200
From: vauban@zeneffy.fr
To: vauban@zeneffy.fr
Subject: [Vauban.zeneffy.fr] You have lost an user :(
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Lost user</h1>

<p>Dear site administrator,</p>
<p>
Sorry but an user deleted its account from Vauban today.
</p>
<p>
<b>User</b>: test2<br/>
<b>User's email</b>: test2@fr.fr<br/>
<b>deleted at</b>: Fri Oct 22 20:38:15 +0200 2010
</p>

</body>
</html>
Redirected to http://127.0.0.1:3000/
Completed in 114ms (DB: 1) | 302 Found [http://127.0.0.1/users/delete]


Processing ApplicationController#index (for 127.0.0.1 at 2010-10-22 20:38:15) [GET]
Parameters: {"action"=>"index", "controller"=>"application"}
Rendering template within layouts/application
Rendering application/index
Completed in 18ms (View: 16, DB: 0) | 200 OK [http://127.0.0.1/]


Processing UserSessionsController#new (for 127.0.0.1 at 2010-10-22 20:38:41) [GET]
Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 97ms (View: 7, DB: 0) | 200 OK [http://127.0.0.1/login]


Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-22 20:38:45) [POST]
Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"[FILTERED]", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"user_sessions"}
User Load (0.2ms) SELECT * FROM "users" WHERE (LOWER("users".username) = 'test2') LIMIT 1
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 23ms (View: 8, DB: 0) | 200 OK [http://127.0.0.1/user_sessions]


Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-22 20:38:53) [POST]
Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"[FILTERED]", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"user_sessions"}
User Load (0.1ms) SELECT * FROM "users" WHERE (LOWER("users".username) = 'test1') LIMIT 1
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 22ms (View: 9, DB: 0) | 200 OK [http://127.0.0.1/user_sessions]


Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-22 20:38:59) [POST]
Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"[FILTERED]", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"user_sessions"}
User Load (0.1ms) SELECT * FROM "users" WHERE (LOWER("users".username) = 'test3') LIMIT 1
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 107ms (View: 19, DB: 0) | 200 OK [http://127.0.0.1/user_sessions]


Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-22 20:39:04) [POST]
Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"[FILTERED]", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"user_sessions"}
User Load (0.2ms) SELECT * FROM "users" WHERE (LOWER("users".username) = 'test4') LIMIT 1
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 29ms (View: 13, DB: 0) | 200 OK [http://127.0.0.1/user_sessions]


Processing UserSessionsController#new (for 127.0.0.1 at 2010-10-22 20:39:41) [GET]
Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 19ms (View: 6, DB: 0) | 200 OK [http://127.0.0.1/login]


Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-22 20:39:47) [POST]
Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"[FILTERED]", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"user_sessions"}
User Load (0.2ms) SELECT * FROM "users" WHERE (LOWER("users".username) = 'test') LIMIT 1
User Update (0.2ms) UPDATE "users" SET "updated_at" = '2010-10-22 18:39:47', "perishable_token" = 'hEz7XN3rSaE11w0VC8G' WHERE "id" = 1
Redirected to http://127.0.0.1:3000/identities
Completed in 19ms (DB: 0) | 302 Found [http://127.0.0.1/user_sessions]


Processing IdentitiesController#index (for 127.0.0.1 at 2010-10-22 20:39:47) [GET]
Parameters: {"action"=>"index", "controller"=>"identities"}
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."id" = '1') LIMIT 1
Identity Load (0.4ms) SELECT * FROM "identities" WHERE ("identities".user_id = 1) ORDER BY name,created_at
Rendering template within layouts/application
Rendering identities/index
Completed in 30ms (View: 9, DB: 1) | 200 OK [http://127.0.0.1/identities]


Processing UserSessionsController#destroy (for 127.0.0.1 at 2010-10-22 20:39:48) [GET]
Parameters: {"action"=>"destroy", "controller"=>"user_sessions"}
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."id" = '1') LIMIT 1
CACHE (0.0ms) SELECT * FROM "users" WHERE ("users"."id" = '1') LIMIT 1
Redirected to http://127.0.0.1:3000/
Completed in 20ms (DB: 0) | 302 Found [http://127.0.0.1/logout]


Processing ApplicationController#index (for 127.0.0.1 at 2010-10-22 20:39:48) [GET]
Parameters: {"action"=>"index", "controller"=>"application"}
Rendering template within layouts/application
Rendering application/index
Completed in 22ms (View: 18, DB: 0) | 200 OK [http://127.0.0.1/]


Processing UserSessionsController#new (for 127.0.0.1 at 2010-10-22 20:39:50) [GET]
Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 20ms (View: 7, DB: 0) | 200 OK [http://127.0.0.1/login]


Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-22 20:39:54) [POST]
Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"[FILTERED]", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"CcX5zcJ6ClVt++Vi7CBpcyWZIDSHRvsZOqTA3mDlQpw=", "controller"=>"user_sessions"}
User Load (0.2ms) SELECT * FROM "users" WHERE (LOWER("users".username) = 'test') LIMIT 1
User Update (0.2ms) UPDATE "users" SET "updated_at" = '2010-10-22 18:39:54', "perishable_token" = '1vYe1K2newvD72ukWGBI' WHERE "id" = 1
Redirected to http://127.0.0.1:3000/identities
Completed in 20ms (DB: 0) | 302 Found [http://127.0.0.1/user_sessions]


Processing IdentitiesController#index (for 127.0.0.1 at 2010-10-22 20:39:54) [GET]
Parameters: {"action"=>"index", "controller"=>"identities"}
User Load (0.3ms) SELECT * FROM "users" WHERE ("users"."id" = '1') LIMIT 1
Identity Load (0.5ms) SELECT * FROM "identities" WHERE ("identities".user_id = 1) ORDER BY name,created_at
Rendering template within layouts/application
Rendering identities/index
Completed in 32ms (View: 9, DB: 1) | 200 OK [http://127.0.0.1/identities]

0 comments on commit 69e27fe

Please sign in to comment.