12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- --[[
- Descripttion:玩家信息
- version:
- Author: Neo,Huang
- Date: 2021-09-15 19:47:54
- LastEditors: Neo,Huang
- LastEditTime: 2021-09-15 19:47:55
- --]]
- local code = require("code")
- local timeUtil = require("utils.timeUtil")
- local moduleData = require("data.module")
- local MODULE_NAME = "player"
- local root = {}
- -- 更新验证码
- function root:update_verify_code(uid)
- if is_empty(uid) or is_robot(uid) then
- return
- end
- local r = {}
- for i = 1, 6 do
- table.insert(r, string.char(math.random(48, 57)))
- end
- local vcode = table.concat(r)
- local vcodeInfo = {vcode = vcode, timeout = timeUtil.now(uid) + 60}
- moduleData:hset(uid, MODULE_NAME, "vcodeInfo", vcodeInfo)
- return vcode
- end
- -- 获取验证码
- function root:get_verify_code(uid)
- if is_empty(uid) or is_robot(uid) then
- return
- end
- local vcodeInfo = moduleData:hget_json(uid, MODULE_NAME, "vcodeInfo")
- if is_empty(vcodeInfo) or is_empty(vcodeInfo.vcode) then
- return code.VERIFY_CODE.VERIFY_CODE
- end
- local currTime = timeUtil.now(uid)
- if currTime > (vcodeInfo.timeout or 0) then
- return code.VERIFY_CODE.TIME_OUT
- end
- return code.OK, vcodeInfo.vcode
- end
- return root
|