|
|
@ -262,6 +262,10 @@ def validate_response(challenge, token, user_id, operation, key, db)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def generate_captcha(key, db)
|
|
|
|
def generate_captcha(key, db)
|
|
|
|
|
|
|
|
second = Random::Secure.rand(12)
|
|
|
|
|
|
|
|
second_angle = second * 30
|
|
|
|
|
|
|
|
second = second * 5
|
|
|
|
|
|
|
|
|
|
|
|
minute = Random::Secure.rand(12)
|
|
|
|
minute = Random::Secure.rand(12)
|
|
|
|
minute_angle = minute * 30
|
|
|
|
minute_angle = minute * 30
|
|
|
|
minute = minute * 5
|
|
|
|
minute = minute * 5
|
|
|
@ -290,6 +294,7 @@ def generate_captcha(key, db)
|
|
|
|
<text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>
|
|
|
|
<text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>
|
|
|
|
|
|
|
|
|
|
|
|
<circle cx="50" cy="50" r="3" fill="black"></circle>
|
|
|
|
<circle cx="50" cy="50" r="3" fill="black"></circle>
|
|
|
|
|
|
|
|
<line id="second" transform="rotate(#{second_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="12" fill="black" stroke="black" stroke-width="1"></line>
|
|
|
|
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
|
|
|
|
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
|
|
|
|
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
|
|
|
|
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
|
|
|
|
</svg>
|
|
|
|
</svg>
|
|
|
@ -303,7 +308,7 @@ def generate_captcha(key, db)
|
|
|
|
image = "data:image/png;base64,#{image}"
|
|
|
|
image = "data:image/png;base64,#{image}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
answer = "#{hour}:#{minute.to_s.rjust(2, '0')}"
|
|
|
|
answer = "#{hour}:#{minute.to_s.rjust(2, '0')}:#{second.to_s.rjust(2, '0')}"
|
|
|
|
answer = OpenSSL::HMAC.hexdigest(:sha256, key, answer)
|
|
|
|
answer = OpenSSL::HMAC.hexdigest(:sha256, key, answer)
|
|
|
|
|
|
|
|
|
|
|
|
challenge, token = create_response(answer, "sign_in", key, db)
|
|
|
|
challenge, token = create_response(answer, "sign_in", key, db)
|
|
|
|