16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/omniauth/strategies/trezor.rb', line 16
def request_phase
session['omniauth.trezor_visual_challenge'] = options[:visual_challenge]
session['omniauth.trezor_hidden_challenge'] = options[:hidden_challenge]
OmniAuth::Form.build(
title: "Trezor Login",
url: callback_path,
header_info: <<-HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js" type="text/javascript"></script>
<script src="https://trezor.github.io/connect/login.js"></script>
<script type='text/javascript'>
function trezorLogin() {
TrezorConnect.requestLogin('#{options[:hosticon]}', '#{options[:hidden_challenge]}', '#{options[:visual_challenge]}', function (result) {
if (result.success) {
$('input[name=public_key]').val(result.public_key);
$('input[name=signature]').val(result.signature);
$('form').submit();
} else {
console.log('Error:', result.error);
}
});
}
$(function() {
$('button').click(function() {
trezorLogin();
return false;
});
});
</script>
HTML
) do |f|
f.input_field('hidden', 'public_key')
f.input_field('hidden', 'signature')
f.html "<p>Logging in at: #{options[:visual_challenge]}</p>"
end.to_response
end
|