Commit e41b320d by liyijie

generate valid code method return code

parent 9f81e3ab
......@@ -37,7 +37,8 @@ module RailsApiAuthentication
def generate_valid_code name
code = (0..9).to_a.sample(@valid_length).join
$redis.setex(name, @valid_expire, code)
$redis.setex("#{self}::#{name}", @valid_expire, code)
code
end
def login(name, password)
......@@ -81,7 +82,7 @@ module RailsApiAuthentication
end
def valid? name, valid_code
@valid_key.blank? || (valid_code.present? && valid_code == $redis.get(name))
@valid_key.blank? || (valid_code.present? && valid_code == $redis.get("#{self}::#{name}))
end
def auth(request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment