使用自定义故障类实现设计用于检测用户是否未确认的触发器是什么? warden_message不起作用。有人知道吗?
class CustomFailure < Devise::FailureApp
def redirect_url
if warden_options[:scope] == :user
new_user_registration_path
else
new_user_registration_path
end
end
def respond
if http_auth?
http_auth
else
store_location!
flash[:alert] = i18n_message unless flash[:notice]
if warden_message == :unconfirmed
redirect_to "/confirm"
else
redirect_to sign_in_path
end
end
end
end
答案 0 :(得分:7)
如果您想将用户重定向到自定义网址,则应该在redirect_url
而不是respond
中执行此操作:
def redirect_url
if warden_message == :unconfirmed
'/confirm'
else
new_user_registration_path
end
end