【发布时间】:2016-08-26 13:43:32
【问题描述】:
local password = json_string["password"] or "None"
local redisPassword = red:hmget(userName,"password") or None
local redisAuthtoken = red:hmget(userName,"authToken")
if (tostring(password) == tostring(redisPassword))
then
ngx.say(redisAuthtoken)
else
ngx.say("Error User or Service Not found 1510")
end
密码 = 管理员 redisPassword = 管理员
我可以看到两个密码作为输出管理员,但它在 lua 代码中不匹配,并且控制总是转到其他部分。
当我这样比较时
if (tostring(password) == "admin" )
它工作正常,这意味着问题出在 redis 值上,但我在 redis 中设置了密码值 admin。
【问题讨论】:
-
变量
None包含什么?
标签: nginx lua redis string-comparison openresty