我在Rails 5中使用Authlogic(3.4.6)来处理身份验证。
而不是%let list = A B C D;
%macro maxvalue;
data want;
set have;
%do j = 1 %to %sysfunc(countw(&list.));
%let i = %scan(&list.,&j.);
value_&i.= Sale_&i. - int_&i.
%end;
max_value = max(
%do x = 1 %to %sysfunc(countw(&list.));
%let y = %scan(&list.,&x.);
value_&y.,
%end; .
);
run;
%mend maxvalue;
%maxvalue;
,我得到了:
UserSession
我还有一个class ClientInfoSession < Authlogic::Session::Base
end
模型,就像ClientInfo
模型:
User
其中class ClientInfo < ApplicationRecord
validates :client_key, presence: true
validates :client_id, presence: true, uniqueness: { scope: [:client_key] }
acts_as_authentic do |c|
c.login_field = :client_id
c.crypted_password_field = :client_key
c.crypto_provider = nil
end
end
是字符串(如用户名),client_id
就像密码。
以下方法是尝试创建会话的操作。它会收到两个参数:client_key
和client_id
:
client_key
这在当地有效;客户端已成功通过身份验证。但是,在生产环境中,身份验证无法正常运行。
在本地创建一个名为 def create
client_info = ClientInfo.find_by(client_id: params[:client_id],
client_key: params[:client_key])
# Yes, I know I shouldn't keep passwords in the DB, but this
# is not being used by anyone yet
@client_info_session = ClientInfoSession.new(client_info)
if @client_info_session.save
redirect_to root_path
else
flash[:error] = 'Invalid user'
render :new
end
end
的cookie并且具有合理的值(非常长的字符串),在生产中,此cookie总是具有类似于client_info_credentials
的值(它根据客户端ID而变化)和关键,但不是很多)。奇怪的是,%3A%3A151
确实返回@client_info_session.save
,因为重定向正在发生,而不是true
。
但是,服务器在任何后续请求中都没有检测到任何用户的cookie,因此就像没有登录一样。