2017-12-04 9 views
0

현재 계좌 잠금 해제시 리디렉션 URL을 변경하는 방법을 찾으려고합니다. 현재 계정이 잠겨있을 때 사용자는 계정 잠금을 해제하는 이메일을 받고 있지만 te 사용자는 기본 URL로 리디렉션됩니다. 내 레일 프로젝트는 API이기 때문에 하나의 새로운 컨트롤러를 작성하고 귀하의 경우에 상속하여 기본 컨트롤러를 재정의해야합니다,Rails/Devise (Devise token auth) 계좌 해지시 리디렉션

Started GET "/api/auth/unlock?unlock_token=YvR4nNssxhB9h8hvDAse" for 
127.0.0.1 at 2017-12-04 15:28:08 -0500 
Processing by Devise::UnlocksController#show as JSON 
Parameters: {"unlock_token"=>"YvR4nNssxhB9h8hvDAse"} 
User Load (0.8ms) SELECT "users".* FROM "users" WHERE 
"users"."unlock_token" = $1 ORDER BY "users"."id" ASC LIMIT $2 
[["unlock_token", 
"6f3c4d7aa5254e143f89cd7f187e22ce56b11e6abe1f5eb252e34d86ac101908"], 
["LIMIT", 1]] 
(0.1ms) BEGIN 
SQL (0.7ms) UPDATE "users" SET "locked_at" = $1, "failed_attempts" = $2, 
"unlock_token" = $3, "updated_at" = $4 WHERE "users"."id" = $5 
[["locked_at", nil], ["failed_attempts", 0], ["unlock_token", nil], 
["updated_at", "2017-12-04 20:28:08.783744"], ["id", 1]] 
(3.4ms) COMMIT 
Redirected to http://localhost:3000/api/auth/sign_in 
Completed 302 Found in 17ms (ActiveRecord: 5.0ms) 


Started GET "/api/auth/sign_in" for 127.0.0.1 at 2017-12-04 15:28:08 
-0500 
Processing by DeviseTokenAuth::SessionsController#new as JSON 
[active_model_serializers] Rendered ActiveModel::Serializer::Null with 
Hash (0.14ms) 
Completed 405 Method Not Allowed in 2ms (Views: 0.9ms | ActiveRecord: 
0.0ms) 


Started GET "/api/auth/sign_in" for 127.0.0.1 at 2017-12-04 15:31:26 
-0500 
Processing by DeviseTokenAuth::SessionsController#new as JSON 
[active_model_serializers] Rendered ActiveModel::Serializer::Null with 
Hash (0.11ms) 
Completed 405 Method Not Allowed in 1ms (Views: 0.7ms | ActiveRecord: 
0.0ms) 

답변

0

가 고안있는 모든 사용자 정의를 위해 내 프런트 엔드로 리디렉션하는 것이 좋을 것이다 그 고안 될 :: UnlocksController 예를 들어

: 경로에 CustomUnlocksController < Devise::UnlocksController

https://github.com/plataformatec/devise/blob/master/app/controllers/devise/unlocks_controller.rb

재정 after_unlock_path_for whic h 다음에 리디렉션 할 예정입니다.

+0

감사합니다. 당신의 도움으로 완벽하게 작동하게 만들 수있었습니다 :-) – marting