Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供一个captcha ID 的接口会不会更好用? #76

Open
qbig opened this issue Mar 12, 2019 · 0 comments
Open

提供一个captcha ID 的接口会不会更好用? #76

qbig opened this issue Mar 12, 2019 · 0 comments

Comments

@qbig
Copy link

qbig commented Mar 12, 2019

先在captcha 的索引是通过rucaptcha_sesion_key_key 来存在session 里面的。但是如果是无状态的API 接口的话(移动端),就不太好用了。

像这样把captcha 在存储中的key 返回,就可以支持不用cookie 的API了

  def new_generate_rucaptcha
    res = RuCaptcha.generate()
    session_val = {
        code: res[0],
        time: Time.now.to_i
    }
    RuCaptcha.cache.write(rucaptcha_sesion_key_key, session_val, expires_in: RuCaptcha.config.expires_in)
    opts = { disposition: 'inline', type: 'image/gif', filename: rucaptcha_sesion_key_key }
    send_data  res[1], opts
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant