devise-authy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +138 -0
- data/LICENSE.txt +20 -0
- data/README.md +86 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/app/assets/javascripts/devise_authy.js +7 -0
- data/app/assets/stylesheets/devise_authy.css +26 -0
- data/app/assets/stylesheets/devise_authy.sass +23 -0
- data/app/controllers/devise/devise_authy_controller.rb +109 -0
- data/app/views/devise/enable_authy.html.erb +8 -0
- data/app/views/devise/enable_authy.html.haml +8 -0
- data/app/views/devise/verify_authy.html.erb +13 -0
- data/app/views/devise/verify_authy.html.haml +11 -0
- data/app/views/devise/verify_authy_installation.html.erb +10 -0
- data/app/views/devise/verify_authy_installation.html.haml +8 -0
- data/authy-devise-demo/.gitignore +15 -0
- data/authy-devise-demo/Gemfile +39 -0
- data/authy-devise-demo/Gemfile.lock +134 -0
- data/authy-devise-demo/README.md +64 -0
- data/authy-devise-demo/Rakefile +7 -0
- data/authy-devise-demo/app/assets/images/rails.png +0 -0
- data/authy-devise-demo/app/assets/javascripts/application.js +15 -0
- data/authy-devise-demo/app/assets/javascripts/devise_authy.js +7 -0
- data/authy-devise-demo/app/assets/javascripts/welcome.js.coffee +3 -0
- data/authy-devise-demo/app/assets/stylesheets/application.css +13 -0
- data/authy-devise-demo/app/assets/stylesheets/devise_authy.css +26 -0
- data/authy-devise-demo/app/assets/stylesheets/welcome.css.scss +3 -0
- data/authy-devise-demo/app/controllers/application_controller.rb +3 -0
- data/authy-devise-demo/app/controllers/welcome_controller.rb +6 -0
- data/authy-devise-demo/app/helpers/application_helper.rb +2 -0
- data/authy-devise-demo/app/helpers/welcome_helper.rb +2 -0
- data/authy-devise-demo/app/mailers/.gitkeep +0 -0
- data/authy-devise-demo/app/models/.gitkeep +0 -0
- data/authy-devise-demo/app/models/user.rb +11 -0
- data/authy-devise-demo/app/views/devise/devise_authy/enable_authy.html.erb +8 -0
- data/authy-devise-demo/app/views/devise/devise_authy/verify_authy.html.erb +13 -0
- data/authy-devise-demo/app/views/devise/devise_authy/verify_authy_installation.html.erb +10 -0
- data/authy-devise-demo/app/views/layouts/application.html.erb +18 -0
- data/authy-devise-demo/app/views/welcome/index.html.erb +5 -0
- data/authy-devise-demo/config.ru +4 -0
- data/authy-devise-demo/config/application.rb +62 -0
- data/authy-devise-demo/config/boot.rb +6 -0
- data/authy-devise-demo/config/database.yml +25 -0
- data/authy-devise-demo/config/environment.rb +5 -0
- data/authy-devise-demo/config/environments/development.rb +37 -0
- data/authy-devise-demo/config/environments/production.rb +67 -0
- data/authy-devise-demo/config/environments/test.rb +37 -0
- data/authy-devise-demo/config/initializers/authy.rb +1 -0
- data/authy-devise-demo/config/initializers/backtrace_silencers.rb +7 -0
- data/authy-devise-demo/config/initializers/devise.rb +232 -0
- data/authy-devise-demo/config/initializers/inflections.rb +15 -0
- data/authy-devise-demo/config/initializers/mime_types.rb +5 -0
- data/authy-devise-demo/config/initializers/secret_token.rb +7 -0
- data/authy-devise-demo/config/initializers/session_store.rb +8 -0
- data/authy-devise-demo/config/initializers/wrap_parameters.rb +14 -0
- data/authy-devise-demo/config/locales/devise.authy.en.yml +18 -0
- data/authy-devise-demo/config/locales/devise.en.yml +58 -0
- data/authy-devise-demo/config/locales/en.yml +5 -0
- data/authy-devise-demo/config/routes.rb +62 -0
- data/authy-devise-demo/db/migrate/20130409234357_devise_create_users.rb +46 -0
- data/authy-devise-demo/db/migrate/20130409234434_devise_authy_add_to_users.rb +18 -0
- data/authy-devise-demo/db/schema.rb +38 -0
- data/authy-devise-demo/db/seeds.rb +7 -0
- data/authy-devise-demo/lib/assets/.gitkeep +0 -0
- data/authy-devise-demo/lib/tasks/.gitkeep +0 -0
- data/authy-devise-demo/log/.gitkeep +0 -0
- data/authy-devise-demo/public/404.html +26 -0
- data/authy-devise-demo/public/422.html +26 -0
- data/authy-devise-demo/public/500.html +25 -0
- data/authy-devise-demo/public/favicon.ico +0 -0
- data/authy-devise-demo/public/robots.txt +5 -0
- data/authy-devise-demo/script/rails +6 -0
- data/authy-devise-demo/test/fixtures/.gitkeep +0 -0
- data/authy-devise-demo/test/fixtures/users.yml +11 -0
- data/authy-devise-demo/test/functional/.gitkeep +0 -0
- data/authy-devise-demo/test/functional/welcome_controller_test.rb +9 -0
- data/authy-devise-demo/test/integration/.gitkeep +0 -0
- data/authy-devise-demo/test/performance/browsing_test.rb +12 -0
- data/authy-devise-demo/test/test_helper.rb +13 -0
- data/authy-devise-demo/test/unit/.gitkeep +0 -0
- data/authy-devise-demo/test/unit/helpers/welcome_helper_test.rb +4 -0
- data/authy-devise-demo/test/unit/user_test.rb +7 -0
- data/authy-devise-demo/vendor/assets/javascripts/.gitkeep +0 -0
- data/authy-devise-demo/vendor/assets/stylesheets/.gitkeep +0 -0
- data/authy-devise-demo/vendor/plugins/.gitkeep +0 -0
- data/config/locales/en.yml +18 -0
- data/devise-authy.gemspec +223 -0
- data/lib/devise-authy.rb +22 -0
- data/lib/devise-authy/controllers/helpers.rb +39 -0
- data/lib/devise-authy/controllers/view_helpers.rb +36 -0
- data/lib/devise-authy/hooks/authy_authenticatable.rb +7 -0
- data/lib/devise-authy/models/authy_authenticatable.rb +23 -0
- data/lib/devise-authy/rails.rb +11 -0
- data/lib/devise-authy/routes.rb +20 -0
- data/lib/devise-authy/version.rb +3 -0
- data/lib/generators/active_record/devise_authy_generator.rb +13 -0
- data/lib/generators/active_record/templates/migration.rb +18 -0
- data/lib/generators/devise_authy/devise_authy_generator.rb +30 -0
- data/lib/generators/devise_authy/install_generator.rb +64 -0
- data/spec/controllers/devise_authy_controller_spec.rb +85 -0
- data/spec/generators_spec.rb +24 -0
- data/spec/integration/authy_authenticatable.rb +88 -0
- data/spec/models/authy_authenticatable.rb +17 -0
- data/spec/orm/active_record.rb +4 -0
- data/spec/rails_app/Rakefile +10 -0
- data/spec/rails_app/app/assets/images/rails.png +0 -0
- data/spec/rails_app/app/assets/javascripts/application.js +10 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +9 -0
- data/spec/rails_app/app/assets/stylesheets/devise_authy.css +26 -0
- data/spec/rails_app/app/assets/stylesheets/devise_authy.css.scss +26 -0
- data/spec/rails_app/app/assets/stylesheets/scaffolds.css.scss +56 -0
- data/spec/rails_app/app/controllers/application_controller.rb +4 -0
- data/spec/rails_app/app/controllers/posts_controller.rb +83 -0
- data/spec/rails_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails_app/app/helpers/posts_helper.rb +2 -0
- data/spec/rails_app/app/mailers/.gitkeep +0 -0
- data/spec/rails_app/app/models/.gitkeep +0 -0
- data/spec/rails_app/app/models/post.rb +2 -0
- data/spec/rails_app/app/models/user.rb +9 -0
- data/spec/rails_app/app/views/devise/devise_authy/register.html.erb +10 -0
- data/spec/rails_app/app/views/devise/devise_authy/show.html.erb +10 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +24 -0
- data/spec/rails_app/app/views/posts/_form.html.erb +25 -0
- data/spec/rails_app/app/views/posts/edit.html.erb +6 -0
- data/spec/rails_app/app/views/posts/index.html.erb +27 -0
- data/spec/rails_app/app/views/posts/new.html.erb +5 -0
- data/spec/rails_app/app/views/posts/show.html.erb +15 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +33 -0
- data/spec/rails_app/config/boot.rb +7 -0
- data/spec/rails_app/config/database.yml +22 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +37 -0
- data/spec/rails_app/config/environments/production.rb +67 -0
- data/spec/rails_app/config/environments/test.rb +37 -0
- data/spec/rails_app/config/initializers/authy.rb +3 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/devise.rb +237 -0
- data/spec/rails_app/config/initializers/inflections.rb +10 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/rails_app/config/initializers/session_store.rb +8 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/devise.authy.en.yml +14 -0
- data/spec/rails_app/config/routes.rb +6 -0
- data/spec/rails_app/db/migrate/20121029205626_devise_create_users.rb +32 -0
- data/spec/rails_app/db/migrate/20121029205627_create_posts.rb +10 -0
- data/spec/rails_app/db/migrate/20121029205628_devise_authy_add_to_users.rb +15 -0
- data/spec/rails_app/db/schema.rb +43 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/script/rails +6 -0
- data/spec/routing/routes_spec.rb +19 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/helpers.rb +28 -0
- metadata +367 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
<h2><%= I18n.t('authy_register_title', {:scope => 'devise'}) %></h2>
|
2
|
+
|
3
|
+
<%= enable_authy_form do %>
|
4
|
+
<%= text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => I18n.t('devise.cellphone'), :id => "authy-cellphone"%>
|
5
|
+
<%= text_field_tag :country_code, '', :autocomplete => :off, :placeholder => I18n.t('devise.country'), :id => "authy-countries"%>
|
6
|
+
<p><%= submit_tag I18n.t('enable_authy', {:scope => 'devise'}) %></p>
|
7
|
+
<% end %>
|
8
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
%h2= I18n.t('authy_register_title', {:scope => 'devise'})
|
2
|
+
= enable_authy_form do
|
3
|
+
= text_field_tag :cellphone, '', :autocomplete => :off, :placeholder => |
|
4
|
+
I18n.t('devise.cellphone'), :id => "authy-cellphone" |
|
5
|
+
-#
|
6
|
+
= text_field_tag :country_code, '', :autocomplete => :off, :placeholder => |
|
7
|
+
I18n.t('devise.country'), :id => "authy-countries" |
|
8
|
+
%p= submit_tag I18n.t('enable_authy', {:scope => 'devise'})
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<h2>
|
2
|
+
<%= I18n.t('authy_register_title', {:scope => 'devise'}) %>
|
3
|
+
</h2>
|
4
|
+
|
5
|
+
<%= verify_authy_form do %>
|
6
|
+
<legend><%= I18n.t('submit_token_title', {:scope => 'devise'}) %></legend>
|
7
|
+
<%= label_tag :token %>
|
8
|
+
<%= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token' %>
|
9
|
+
<%= link_to '?', '#', :id => 'authy-help' %>
|
10
|
+
<%= authy_request_sms_link %>
|
11
|
+
<%= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn' %>
|
12
|
+
<% end %>
|
13
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%h2= I18n.t('authy_register_title', {:scope => 'devise'})
|
2
|
+
|
3
|
+
= verify_authy_form do
|
4
|
+
%legend= I18n.t('submit_token_title', {:scope => 'devise'})
|
5
|
+
= hidden_field_tag :"#{resource_name}_id", @resource.id
|
6
|
+
= label_tag :token
|
7
|
+
= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token'
|
8
|
+
= link_to '?', '#', :id => 'authy-help'
|
9
|
+
= authy_request_sms_link
|
10
|
+
= submit_tag I18n.t('submit_token', {:scope => 'devise'}), :class => 'btn'
|
11
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h2><%= I18n.t('authy_verify_installation_title', {:scope => 'devise'}) %></h2>
|
2
|
+
|
3
|
+
<%= verify_authy_installation_form do %>
|
4
|
+
<legend><%= I18n.t('submit_token_title', {:scope => 'devise'}) %></legend>
|
5
|
+
<%= label_tag :token %>
|
6
|
+
<%= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token' %>
|
7
|
+
<%= authy_request_sms_link %>
|
8
|
+
<%= submit_tag I18n.t('enable_my_account', {:scope => 'devise'}), :class => 'btn' %>
|
9
|
+
<% end %>
|
10
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
%h2= I18n.t('authy_verify_installation_title', {:scope => 'devise'})
|
2
|
+
= verify_authy_installation_form do
|
3
|
+
%legend= I18n.t('submit_token_title', {:scope => 'devise'})
|
4
|
+
= label_tag :token
|
5
|
+
= text_field_tag :token, "", :autocomplete => :off, :id => 'authy-token'
|
6
|
+
= authy_request_sms_link
|
7
|
+
= submit_tag I18n.t('enable_my_account', {:scope => 'devise'}), :class => 'btn'
|
8
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
@@ -0,0 +1,39 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.2.13'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'sqlite3'
|
9
|
+
gem 'devise', '2.1.3'
|
10
|
+
gem 'devise-authy', :path => ".."
|
11
|
+
|
12
|
+
# Gems used only for assets and not required
|
13
|
+
# in production environments by default.
|
14
|
+
group :assets do
|
15
|
+
gem 'sass-rails', '~> 3.2.3'
|
16
|
+
gem 'coffee-rails', '~> 3.2.1'
|
17
|
+
|
18
|
+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
19
|
+
# gem 'therubyracer', :platforms => :ruby
|
20
|
+
|
21
|
+
gem 'uglifier', '>= 1.0.3'
|
22
|
+
end
|
23
|
+
|
24
|
+
gem 'jquery-rails'
|
25
|
+
|
26
|
+
# To use ActiveModel has_secure_password
|
27
|
+
# gem 'bcrypt-ruby', '~> 3.0.0'
|
28
|
+
|
29
|
+
# To use Jbuilder templates for JSON
|
30
|
+
# gem 'jbuilder'
|
31
|
+
|
32
|
+
# Use unicorn as the app server
|
33
|
+
# gem 'unicorn'
|
34
|
+
|
35
|
+
# Deploy with Capistrano
|
36
|
+
# gem 'capistrano'
|
37
|
+
|
38
|
+
# To use debugger
|
39
|
+
# gem 'debugger'
|
@@ -0,0 +1,134 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
devise-authy (1.0.0)
|
5
|
+
authy
|
6
|
+
devise
|
7
|
+
devise-authy
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (3.2.13)
|
13
|
+
actionpack (= 3.2.13)
|
14
|
+
mail (~> 2.5.3)
|
15
|
+
actionpack (3.2.13)
|
16
|
+
activemodel (= 3.2.13)
|
17
|
+
activesupport (= 3.2.13)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
journey (~> 1.0.4)
|
21
|
+
rack (~> 1.4.5)
|
22
|
+
rack-cache (~> 1.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.2.1)
|
25
|
+
activemodel (3.2.13)
|
26
|
+
activesupport (= 3.2.13)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
activerecord (3.2.13)
|
29
|
+
activemodel (= 3.2.13)
|
30
|
+
activesupport (= 3.2.13)
|
31
|
+
arel (~> 3.0.2)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activeresource (3.2.13)
|
34
|
+
activemodel (= 3.2.13)
|
35
|
+
activesupport (= 3.2.13)
|
36
|
+
activesupport (3.2.13)
|
37
|
+
i18n (= 0.6.1)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
arel (3.0.2)
|
40
|
+
authy (1.1.0)
|
41
|
+
httpclient
|
42
|
+
bcrypt-ruby (3.0.1)
|
43
|
+
builder (3.0.4)
|
44
|
+
coffee-rails (3.2.2)
|
45
|
+
coffee-script (>= 2.2.0)
|
46
|
+
railties (~> 3.2.0)
|
47
|
+
coffee-script (2.2.0)
|
48
|
+
coffee-script-source
|
49
|
+
execjs
|
50
|
+
coffee-script-source (1.6.2)
|
51
|
+
devise (2.1.3)
|
52
|
+
bcrypt-ruby (~> 3.0)
|
53
|
+
orm_adapter (~> 0.1)
|
54
|
+
railties (~> 3.1)
|
55
|
+
warden (~> 1.2.1)
|
56
|
+
erubis (2.7.0)
|
57
|
+
execjs (1.4.0)
|
58
|
+
multi_json (~> 1.0)
|
59
|
+
hike (1.2.2)
|
60
|
+
httpclient (2.3.3)
|
61
|
+
i18n (0.6.1)
|
62
|
+
journey (1.0.4)
|
63
|
+
jquery-rails (2.2.1)
|
64
|
+
railties (>= 3.0, < 5.0)
|
65
|
+
thor (>= 0.14, < 2.0)
|
66
|
+
json (1.7.7)
|
67
|
+
mail (2.5.3)
|
68
|
+
i18n (>= 0.4.0)
|
69
|
+
mime-types (~> 1.16)
|
70
|
+
treetop (~> 1.4.8)
|
71
|
+
mime-types (1.22)
|
72
|
+
multi_json (1.7.2)
|
73
|
+
orm_adapter (0.4.0)
|
74
|
+
polyglot (0.3.3)
|
75
|
+
rack (1.4.5)
|
76
|
+
rack-cache (1.2)
|
77
|
+
rack (>= 0.4)
|
78
|
+
rack-ssl (1.3.3)
|
79
|
+
rack
|
80
|
+
rack-test (0.6.2)
|
81
|
+
rack (>= 1.0)
|
82
|
+
rails (3.2.13)
|
83
|
+
actionmailer (= 3.2.13)
|
84
|
+
actionpack (= 3.2.13)
|
85
|
+
activerecord (= 3.2.13)
|
86
|
+
activeresource (= 3.2.13)
|
87
|
+
activesupport (= 3.2.13)
|
88
|
+
bundler (~> 1.0)
|
89
|
+
railties (= 3.2.13)
|
90
|
+
railties (3.2.13)
|
91
|
+
actionpack (= 3.2.13)
|
92
|
+
activesupport (= 3.2.13)
|
93
|
+
rack-ssl (~> 1.3.2)
|
94
|
+
rake (>= 0.8.7)
|
95
|
+
rdoc (~> 3.4)
|
96
|
+
thor (>= 0.14.6, < 2.0)
|
97
|
+
rake (10.0.4)
|
98
|
+
rdoc (3.12.2)
|
99
|
+
json (~> 1.4)
|
100
|
+
sass (3.2.7)
|
101
|
+
sass-rails (3.2.6)
|
102
|
+
railties (~> 3.2.0)
|
103
|
+
sass (>= 3.1.10)
|
104
|
+
tilt (~> 1.3)
|
105
|
+
sprockets (2.2.2)
|
106
|
+
hike (~> 1.2)
|
107
|
+
multi_json (~> 1.0)
|
108
|
+
rack (~> 1.0)
|
109
|
+
tilt (~> 1.1, != 1.3.0)
|
110
|
+
sqlite3 (1.3.7)
|
111
|
+
thor (0.18.1)
|
112
|
+
tilt (1.3.7)
|
113
|
+
treetop (1.4.12)
|
114
|
+
polyglot
|
115
|
+
polyglot (>= 0.3.1)
|
116
|
+
tzinfo (0.3.37)
|
117
|
+
uglifier (2.0.1)
|
118
|
+
execjs (>= 0.3.0)
|
119
|
+
multi_json (~> 1.0, >= 1.0.2)
|
120
|
+
warden (1.2.1)
|
121
|
+
rack (>= 1.0)
|
122
|
+
|
123
|
+
PLATFORMS
|
124
|
+
ruby
|
125
|
+
|
126
|
+
DEPENDENCIES
|
127
|
+
coffee-rails (~> 3.2.1)
|
128
|
+
devise (= 2.1.3)
|
129
|
+
devise-authy!
|
130
|
+
jquery-rails
|
131
|
+
rails (= 3.2.13)
|
132
|
+
sass-rails (~> 3.2.3)
|
133
|
+
sqlite3
|
134
|
+
uglifier (>= 1.0.3)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Steps to re-create this demo
|
2
|
+
|
3
|
+
1. Create a new rails application:
|
4
|
+
|
5
|
+
rails new authy-devise-demo
|
6
|
+
rm public/index.html
|
7
|
+
|
8
|
+
2. Add dependencies to Gemfile:
|
9
|
+
|
10
|
+
gem 'devise', '2.1.3'
|
11
|
+
gem 'devise-authy'
|
12
|
+
|
13
|
+
3. Create a root controller
|
14
|
+
|
15
|
+
rails g controller Welcome index
|
16
|
+
|
17
|
+
4. Edit `config/routes.rb` and uncomment:
|
18
|
+
|
19
|
+
root :to => 'welcome#index'
|
20
|
+
|
21
|
+
5. Create `config/initializers/authy.rb` and add:
|
22
|
+
|
23
|
+
Authy.api_key = '<your-api-key>'
|
24
|
+
|
25
|
+
6. Install and configure Devise and Devise Authy
|
26
|
+
|
27
|
+
rails g devise:install
|
28
|
+
rails g devise User
|
29
|
+
rails g devise_authy:install
|
30
|
+
rails g devise_authy User
|
31
|
+
|
32
|
+
7. Create a user
|
33
|
+
|
34
|
+
rake db:migrate
|
35
|
+
rails runner 'User.create(:email => "user@example.com", :password => "password", :password_confirmation => "password")'
|
36
|
+
|
37
|
+
|
38
|
+
8. Edit `app/controllers/welcome_controller.rb` and add:
|
39
|
+
|
40
|
+
before_filter :authenticate_user!
|
41
|
+
|
42
|
+
|
43
|
+
9. Edit `app/views/welcome/index.html.erb` and add:
|
44
|
+
|
45
|
+
<%= link_to "Enable authy", user_enable_authy_path %>
|
46
|
+
<%= link_to "Logout", destroy_user_session_path, :method => :delete %>
|
47
|
+
|
48
|
+
|
49
|
+
10. Done
|
50
|
+
|
51
|
+
|
52
|
+
# Steps to use this demo
|
53
|
+
|
54
|
+
1. Clone the repository
|
55
|
+
|
56
|
+
git clone git://github.com/authy/authy-devise-demo.git
|
57
|
+
|
58
|
+
2. Create a user
|
59
|
+
|
60
|
+
rake db:migrate
|
61
|
+
rails runner 'User.create(:email => "user@example.com", :password => "password", :password_confirmation => "password")'
|
62
|
+
|
63
|
+
3. Done
|
64
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
AuthyDeviseDemo::Application.load_tasks
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,26 @@
|
|
1
|
+
.devise_authy {
|
2
|
+
margin-left: auto;
|
3
|
+
margin-right: auto;
|
4
|
+
width: 350px;
|
5
|
+
}
|
6
|
+
|
7
|
+
legend {
|
8
|
+
display: block;
|
9
|
+
width: 100%;
|
10
|
+
padding: 0;
|
11
|
+
margin-bottom: 20px;
|
12
|
+
font-size: 21px;
|
13
|
+
line-height: 40px;
|
14
|
+
color: #333;
|
15
|
+
border-bottom: 1px solid #E5E5E5;
|
16
|
+
}
|
17
|
+
|
18
|
+
label,
|
19
|
+
input,
|
20
|
+
button {
|
21
|
+
font-size: 14px;
|
22
|
+
font-weight: normal;
|
23
|
+
line-height: 20px;
|
24
|
+
padding: 8px;
|
25
|
+
margin: 8px;
|
26
|
+
}
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
# Include default devise modules. Others available are:
|
3
|
+
# :token_authenticatable, :confirmable,
|
4
|
+
# :lockable, :timeoutable and :omniauthable
|
5
|
+
devise :authy_authenticatable, :database_authenticatable, :registerable,
|
6
|
+
:recoverable, :rememberable, :trackable, :validatable
|
7
|
+
|
8
|
+
# Setup accessible (or protected) attributes for your model
|
9
|
+
attr_accessible :authy_id, :last_sign_in_with_authy, :email, :password, :password_confirmation, :remember_me
|
10
|
+
# attr_accessible :authy_id, :last_sign_in_with_authy, :title, :body
|
11
|
+
end
|