Permalink
Browse files

Merged back in most of my working

  • Loading branch information...
2 parents ba35f2a + bfb9b2c commit 738b72b23a4c28d2b1276cd63641750a0d8b71f4 Christian Frichot committed Jan 22, 2012
Showing with 1,770 additions and 175 deletions.
  1. +15 −1 Gemfile
  2. +95 −35 Gemfile.lock
  3. +2 −1 Rakefile
  4. +1 −1 VERSION
  5. +21 −3 app/controllers/devise/checkga_controller.rb
  6. +4 −3 app/views/devise/checkga/show.html.erb
  7. +4 −4 app/views/devise/displayqr/show.html.erb
  8. +9 −0 config/locales/en.yml
  9. +2 −26 devise_google_authenticator.gemspec
  10. +30 −2 lib/devise_google_authenticatable/models/google_authenticatable.rb
  11. +11 −70 lib/devise_google_authenticatable/patches/check_ga.rb
  12. +8 −0 lib/devise_google_authenticatable/schema.rb
  13. +8 −4 lib/devise_google_authenticator.rb
  14. +13 −0 lib/generators/active_record/devise_google_authenticator_generator.rb
  15. +17 −0 lib/generators/active_record/templates/migration.rb
  16. +19 −0 lib/generators/devise_google_authenticator/devise_google_authenticator_generator.rb
  17. +23 −0 lib/generators/devise_google_authenticator/install_generator.rb
  18. +19 −0 lib/generators/devise_google_authenticator/views_generator.rb
  19. +48 −0 test/generators_test.rb
  20. +0 −18 test/helper.rb
  21. +207 −0 test/integration/invitation_test.rb
  22. +48 −0 test/integration_tests_helper.rb
  23. +59 −0 test/mailers/invitation_mail_test.rb
  24. +33 −0 test/model_tests_helper.rb
  25. +372 −0 test/models/invitable_test.rb
  26. +74 −0 test/models_test.rb
  27. +4 −0 test/orm/active_record.rb
  28. +10 −0 test/orm/mongoid.rb
  29. +6 −0 test/rails_app/app/controllers/admins_controller.rb
  30. +3 −0 test/rails_app/app/controllers/application_controller.rb
  31. +6 −0 test/rails_app/app/controllers/free_invitations_controller.rb
  32. +4 −0 test/rails_app/app/controllers/home_controller.rb
  33. +12 −0 test/rails_app/app/controllers/users_controller.rb
  34. +2 −0 test/rails_app/app/helpers/application_helper.rb
  35. +5 −0 test/rails_app/app/models/admin.rb
  36. +5 −0 test/rails_app/app/models/octopussy.rb
  37. +15 −0 test/rails_app/app/models/user.rb
  38. +12 −0 test/rails_app/app/views/admins/new.html.erb
  39. +12 −0 test/rails_app/app/views/free_invitations/new.html.erb
  40. 0 test/rails_app/app/views/home/index.html.erb
  41. +16 −0 test/rails_app/app/views/layouts/application.html.erb
  42. +15 −0 test/rails_app/app/views/users/invitations/new.html.erb
  43. +4 −0 test/rails_app/config.ru
  44. +25 −0 test/rails_app/config/application.rb
  45. +11 −0 test/rails_app/config/boot.rb
  46. +22 −0 test/rails_app/config/database.yml
  47. +5 −0 test/rails_app/config/environment.rb
  48. +26 −0 test/rails_app/config/environments/development.rb
  49. +49 −0 test/rails_app/config/environments/production.rb
  50. +35 −0 test/rails_app/config/environments/test.rb
  51. +7 −0 test/rails_app/config/initializers/backtrace_silencers.rb
  52. +184 −0 test/rails_app/config/initializers/devise.rb
  53. +10 −0 test/rails_app/config/initializers/inflections.rb
  54. +5 −0 test/rails_app/config/initializers/mime_types.rb
  55. +7 −0 test/rails_app/config/initializers/secret_token.rb
  56. +8 −0 test/rails_app/config/initializers/session_store.rb
  57. +10 −0 test/rails_app/config/locales/en.yml
  58. +12 −0 test/rails_app/config/mongoid.yml
  59. +9 −0 test/rails_app/config/routes.rb
  60. +20 −0 test/rails_app/db/migrate/20100401102949_create_tables.rb
  61. +6 −0 test/rails_app/script/rails
  62. +20 −0 test/routes_test.rb
  63. +5 −0 test/support/locale/en.yml
  64. +0 −7 test/test_devise_google_authenticator.rb
  65. +21 −0 test/test_helper.rb
View
16 Gemfile
@@ -6,10 +6,24 @@ gem "rails"
gem "devise"
gem "rotp"
+# The below are yoinked from devise_invitable's gemfile
+group :test do
+ gem "sqlite3"
+ gem "mongoid", "~> 2.0"
+ gem "bson_ext", "~> 1.3"
+ gem "capybara", "~> 0.4.0"
+ gem 'shoulda', '~> 2.11.3'
+ gem 'mocha', '~> 0.9.9'
+ gem 'factory_girl_rails', '~> 1.0'
+ gem 'rspec-rails', '~> 2.5.0'
+end
+
+# End devise_invitable's gemfile stuff
+
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
- gem "shoulda", ">= 0"
+ gem "shoulda", "~> 2.11.3"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.4"
gem "rcov", ">= 0"
View
@@ -1,59 +1,90 @@
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.1.1)
- actionpack (= 3.1.1)
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
mail (~> 2.3.0)
- actionpack (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
- rack (~> 1.3.2)
+ rack (~> 1.3.5)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
- sprockets (~> 2.0.2)
- activemodel (3.1.1)
- activesupport (= 3.1.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
builder (~> 3.0.0)
i18n (~> 0.6)
- activerecord (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
- activeresource (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
- activesupport (3.1.1)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
multi_json (~> 1.0)
arel (2.2.1)
bcrypt-ruby (3.0.1)
+ bson (1.5.2)
+ bson_ext (1.5.2)
+ bson (= 1.5.2)
builder (3.0.0)
- devise (1.4.9)
+ capybara (0.4.1.2)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.3)
+ celerity (0.9.2)
+ childprocess (0.3.0)
+ ffi (~> 1.0.6)
+ culerity (0.2.15)
+ devise (1.5.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
- warden (~> 1.0.3)
+ warden (~> 1.1)
+ diff-lcs (1.1.3)
erubis (2.7.0)
+ factory_girl (2.4.0)
+ activesupport
+ factory_girl_rails (1.5.0)
+ factory_girl (~> 2.4.0)
+ railties (>= 3.0.0)
+ ffi (1.0.11)
git (1.2.5)
hike (1.2.1)
i18n (0.6.0)
jeweler (1.6.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
- json (1.6.1)
+ json (1.6.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
- multi_json (1.0.3)
- orm_adapter (0.0.5)
+ mocha (0.9.12)
+ mongo (1.5.2)
+ bson (= 1.5.2)
+ mongoid (2.4.0)
+ activemodel (~> 3.1)
+ mongo (~> 1.3)
+ tzinfo (~> 0.3.22)
+ multi_json (1.0.4)
+ nokogiri (1.5.0)
+ orm_adapter (0.0.6)
polyglot (0.3.3)
- rack (1.3.5)
+ rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
@@ -62,48 +93,77 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.1.1)
- actionmailer (= 3.1.1)
- actionpack (= 3.1.1)
- activerecord (= 3.1.1)
- activeresource (= 3.1.1)
- activesupport (= 3.1.1)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
bundler (~> 1.0)
- railties (= 3.1.1)
- railties (3.1.1)
- actionpack (= 3.1.1)
- activesupport (= 3.1.1)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rcov (0.9.11)
- rdoc (3.11)
+ rdoc (3.12)
json (~> 1.4)
rotp (1.3.2)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.2)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ rspec-rails (2.5.0)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.5.0)
+ rubyzip (0.9.5)
+ selenium-webdriver (2.16.0)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0.9)
+ multi_json (~> 1.0.4)
+ rubyzip
shoulda (2.11.3)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
- warden (1.0.6)
+ warden (1.1.0)
rack (>= 1.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ bson_ext (~> 1.3)
bundler (~> 1.0.0)
+ capybara (~> 0.4.0)
devise
+ factory_girl_rails (~> 1.0)
jeweler (~> 1.6.4)
+ mocha (~> 0.9.9)
+ mongoid (~> 2.0)
rails
rcov
rotp
- shoulda
+ rspec-rails (~> 2.5.0)
+ shoulda (~> 2.11.3)
+ sqlite3
View
@@ -15,12 +15,13 @@ require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "devise_google_authenticator"
- gem.homepage = "http://github.com/xntrik/devise_google_authenticator"
+ gem.homepage = "http://github.com/AsteriskLabs/devise_google_authenticator"
gem.license = "MIT"
gem.summary = %Q{Devise Google Authenticator Extension}
gem.description = %Q{Devise Google Authenticator Extension, for adding Google's OTP to your Rails apps!}
gem.email = "xntrik@gmail.com"
gem.authors = ["Christian Frichot"]
+ gem.files = Dir["{app,config,lib}/**/*"] + %w[LICENSE.txt README.rdoc]
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new
View
@@ -1 +1 @@
-0.1.0
+0.2.0
@@ -3,11 +3,29 @@ class Devise::CheckgaController < Devise::SessionsController
include Devise::Controllers::InternalHelpers
def show
- render_with_scope :show
+ @tmpid = params[:id]
+ if @tmpid.nil?
+ redirect_to :root
+ else
+ render_with_scope :show
+ end
end
def update
- sign_in(resource_name, resource)
- respond_with resource, :location => redirect_location(resource_name, resource)
+ resource = resource_class.find_by_gauth_tmp(params[resource_name]['tmpid'])
+
+ if not resource.nil?
+
+ if resource.validate_token(params[resource_name]['token'].to_i)
+ set_flash_message(:notice, :signed_in) if is_navigational_format?
+ sign_in(resource_name,resource)
+ respond_with resource, :location => redirect_location(resource_name, resource)
+ else
+ redirect_to :root
+ end
+
+ else
+ redirect_to :root
+ end
end
end
@@ -1,6 +1,7 @@
-<h2>Submit QR Code</h2>
+<h2><%= I18n.t('submit_token_title', {:scope => 'devise'}) %></h2>
<%= form_for(resource, :as => resource_name, :url => [resource_name, :checkga], :html => { :method => :put }) do |f| %>
-
- <p><%= f.submit "Continue.." %></p>
+ <%= f.hidden_field :tmpid, {:value => @tmpid} %>
+ <%= f.text_field :token, :autocomplete => :off%>
+ <p><%= f.submit I18n.t('submit_token', {:scope => 'devise'}) %></p>
<% end %>
@@ -1,12 +1,12 @@
-<h2>Your QR Code</h2>
+<h2><%= I18n.t('title', {:scope => 'devise.registration'}) %></h2>
<%= google_authenticator_qrcode(resource) %>
<%= form_for(resource, :as => resource_name, :url => [resource_name, :displayqr], :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
- <h3>Would you like to enable Google Authenticator?</h3>
- <p><%= f.label :gauth_enabled, "Google Authenticator Status" %><br />
+ <h3><%= I18n.t('nice_request', {:scope => 'devise.registration'}) %></h3>
+ <p><%= f.label :gauth_enabled, I18n.t('qrstatus', {:scope => 'devise.registration'}) %><br />
<%= f.check_box :gauth_enabled %></p>
- <p><%= f.submit "Continue.." %></p>
+ <p><%= f.submit I18n.t('submit', {:scope => 'devise.registration'}) %></p>
<% end %>
View
@@ -0,0 +1,9 @@
+en:
+ devise:
+ submit_token: "Check Token"
+ submit_token_title: "Please enter your Google Authenticator token:"
+ registration:
+ title: "Your QR Code:"
+ nice_request: "Would you like to enable Google Authenticator?"
+ qrstatus: "Google Authenticator Status:"
+ submit: "Continue..."
@@ -9,38 +9,14 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Christian Frichot"]
- s.date = "2011-11-22"
+ s.date = "2012-01-22"
s.description = "Devise Google Authenticator Extension, for adding Google's OTP to your Rails apps!"
s.email = "xntrik@gmail.com"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
- s.files = [
- ".document",
- "Gemfile",
- "Gemfile.lock",
- "LICENSE.txt",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "app/controllers/devise/checkga_controller.rb",
- "app/controllers/devise/displayqr_controller.rb",
- "app/views/devise/checkga/show.html.erb",
- "app/views/devise/displayqr/show.html.erb",
- "devise_google_authenticator.gemspec",
- "lib/devise_google_authenticatable/controllers/helpers.rb",
- "lib/devise_google_authenticatable/hooks/google_authenticatable.rb",
- "lib/devise_google_authenticatable/models/google_authenticatable.rb",
- "lib/devise_google_authenticatable/orm/active_record.rb",
- "lib/devise_google_authenticatable/patches.rb",
- "lib/devise_google_authenticatable/patches/check_ga.rb",
- "lib/devise_google_authenticatable/patches/display_qr.rb",
- "lib/devise_google_authenticatable/rails.rb",
- "lib/devise_google_authenticatable/routes.rb",
- "lib/devise_google_authenticatable/schema.rb",
- "lib/devise_google_authenticator.rb"
- ]
+ s.files = Dir["{app,config,lib}/**/*"] + %w[LICENSE.txt README.rdoc]
s.homepage = "http://github.com/AsteriskLabs/devise_google_authenticator"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
Oops, something went wrong.

0 comments on commit 738b72b

Please sign in to comment.