5

使用自定义故障类实现,以设计检测用户是否未确认的触发器是什么?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
4

1 回答 1

8

如果您想将用户重定向到自定义 URL,您应该在 中进行redirect_url,而不是在respond

def redirect_url
  if warden_message == :unconfirmed
    '/confirm'
  else
    new_user_registration_path
  end
end
于 2013-06-02T20:00:45.937 回答