Я добавил собственную стратегию, чтобы исправить это:
Warden::Strategies.add(:tokens_authenticatable) do
def valid?
# code here to check whether to try and authenticate using this strategy;
return params.key? :token
end
def authenticate!
# code here for doing authentication;
puts params
token = Token.where(["token = ?", params[:token]]).first
puts token
if (!token.nil?)
# if successful, call
success!(token.user) # where resource is the whatever you've authenticated, e.g. user;
else
# if fail, call
fail!("WWAAAAA") # where message is the failure message
end
end
end
config.warden do |manager|
# manager.intercept_401 = false
manager.default_strategies(:scope => :user).unshift :tokens_authenticatable
end