我做了一个非常基本的设计设置(设计3.3.0,rails 4.1.5,ruby 2.1.1)。
我让它在我的emtpy应用程序中创建模型(rails g devise:install
和rails devise my_user
)
让我们来看看现在的路线(我添加了空行以便更好地观看):
1 new_my_user_session GET /my_users/sign_in(.:format) devise/sessions#new 2 my_user_session POST /my_users/sign_in(.:format) devise/sessions#create 3 destroy_my_user_session DELETE /my_users/sign_out(.:format) devise/sessions#destroy 4 my_user_password POST /my_users/password(.:format) devise/passwords#create 5 new_my_user_password GET /my_users/password/new(.:format) devise/passwords#new 6 edit_my_user_password GET /my_users/password/edit(.:format) devise/passwords#edit 7 PATCH /my_users/password(.:format) devise/passwords#update 8 PUT /my_users/password(.:format) devise/passwords#update 9 cancel_my_user_registration GET /my_users/cancel(.:format) devise/registrations#cancel 10 my_user_registration POST /my_users(.:format) devise/registrations#create 11 new_my_user_registration GET /my_users/sign_up(.:format) devise/registrations#new 12 edit_my_user_registration GET /my_users/edit(.:format) devise/registrations#edit 13 PATCH /my_users(.:format) devise/registrations#update 14 PUT /my_users(.:format) devise/registrations#update 15 DELETE /my_users(.:format) devise/registrations#destroy
现在让我们回顾一下:
[1,2] user sign in (available w/o authentication) [3] user sign out [4,5] forgotten password form (w/o authentication) [6,7,8] editing password? WHAT DOES IT DO THIS? [9] cancel registration? [10,11] user sign up (registration of a new user) [12,13,14] user editing his data [15] user delete himself
我特别感兴趣的是了解6,7,8个动作的意图,它们似乎是在编辑密码,但实际上却没有。事实上,还有另外两种方法,即:
第二个问题是,取消注册行动是做什么的?
此外,my_user / password / edit路由,无论它应该做什么,似乎都无法正常工作。当我浏览它时,我只是被重定向到根页面。 这是日志:
Started GET "/my_users/password/edit" for 127.0.0.1 at 2014-09-22 16:37:04 +0200 Processing by Devise::PasswordsController#edit as HTML MyUser Load (0.7ms) SELECT "my_users".* FROM "my_users" WHERE "my_users"."id" = 5 ORDER BY "my_users"."id" ASC LIMIT 1 Redirected to http://localhost:3000/ Filter chain halted as :require_no_authentication rendered or redirected
答案 0 :(得分:2)
'forgotten password' capability (actions 4,5)
这将为已注册的电子邮件生成新的重置密码令牌。这是忘记密码功能的一部分。
'edit user' capability (actions 12,13,14)
这也是忘记密码功能的一部分。这将找到用户根据重置密码令牌进行编辑,然后更新密码。
The second question is, what does it do the cancel registration action?
这将删除注册期间插入的所有会话数据。像清晰的功能。以下评论设计注册取消行动。链接到这里https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.