Mercurial > prosody-modules
comparison mod_register_web/mod_register_web.lua @ 1231:502ce9672eae
mod_register_web: Use local
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 30 Nov 2013 20:29:21 +0100 |
parents | f7c561fbd5a6 |
children | 12f59489ef6e |
comparison
equal
deleted
inserted
replaced
1230:f7c561fbd5a6 | 1231:502ce9672eae |
---|---|
53 end | 53 end |
54 end); | 54 end); |
55 end | 55 end |
56 else | 56 else |
57 module:log("debug", "No Recaptcha options set, using fallback captcha") | 57 module:log("debug", "No Recaptcha options set, using fallback captcha") |
58 local random = math.random; | |
58 local hmac_sha1 = require "util.hashes".hmac_sha1; | 59 local hmac_sha1 = require "util.hashes".hmac_sha1; |
59 local secret = require "util.uuid".generate() | 60 local secret = require "util.uuid".generate() |
60 local ops = { '+', '-' }; | 61 local ops = { '+', '-' }; |
61 local captcha_tpl = get_template "simplecaptcha"; | 62 local captcha_tpl = get_template "simplecaptcha"; |
62 function generate_captcha() | 63 function generate_captcha() |
63 local op = ops[math.random(1, #ops)]; | 64 local op = ops[random(1, #ops)]; |
64 local x, y = math.random(1, 9) | 65 local x, y = random(1, 9) |
65 repeat | 66 repeat |
66 y = math.random(1, 9); | 67 y = random(1, 9); |
67 until x ~= y; | 68 until x ~= y; |
68 local answer; | 69 local answer; |
69 if op == '+' then | 70 if op == '+' then |
70 answer = x + y; | 71 answer = x + y; |
71 elseif op == '-' then | 72 elseif op == '-' then |