loyal_devise 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.rdoc +881 -0
- data/CONTRIBUTING.md +12 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +154 -0
- data/MIT-LICENSE +20 -0
- data/README.md +388 -0
- data/Rakefile +34 -0
- data/app/controllers/devise/confirmations_controller.rb +44 -0
- data/app/controllers/devise/omniauth_callbacks_controller.rb +31 -0
- data/app/controllers/devise/passwords_controller.rb +57 -0
- data/app/controllers/devise/registrations_controller.rb +120 -0
- data/app/controllers/devise/sessions_controller.rb +51 -0
- data/app/controllers/devise/unlocks_controller.rb +45 -0
- data/app/controllers/devise_controller.rb +193 -0
- data/app/helpers/devise_helper.rb +26 -0
- data/app/mailers/devise/mailer.rb +16 -0
- data/app/views/devise/_links.erb +3 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +17 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/config/locales/en.yml +59 -0
- data/devise.gemspec +26 -0
- data/gemfiles/Gemfile.rails-3.1.x +35 -0
- data/gemfiles/Gemfile.rails-3.1.x.lock +167 -0
- data/lib/devise/controllers/helpers.rb +273 -0
- data/lib/devise/controllers/rememberable.rb +53 -0
- data/lib/devise/controllers/scoped_views.rb +18 -0
- data/lib/devise/controllers/url_helpers.rb +68 -0
- data/lib/devise/delegator.rb +17 -0
- data/lib/devise/failure_app.rb +188 -0
- data/lib/devise/hooks/activatable.rb +12 -0
- data/lib/devise/hooks/forgetable.rb +10 -0
- data/lib/devise/hooks/lockable.rb +8 -0
- data/lib/devise/hooks/rememberable.rb +7 -0
- data/lib/devise/hooks/timeoutable.rb +26 -0
- data/lib/devise/hooks/trackable.rb +10 -0
- data/lib/devise/mailers/helpers.rb +92 -0
- data/lib/devise/mapping.rb +173 -0
- data/lib/devise/models/authenticatable.rb +269 -0
- data/lib/devise/models/confirmable.rb +271 -0
- data/lib/devise/models/database_authenticatable.rb +127 -0
- data/lib/devise/models/lockable.rb +194 -0
- data/lib/devise/models/omniauthable.rb +28 -0
- data/lib/devise/models/recoverable.rb +141 -0
- data/lib/devise/models/registerable.rb +26 -0
- data/lib/devise/models/rememberable.rb +126 -0
- data/lib/devise/models/timeoutable.rb +50 -0
- data/lib/devise/models/token_authenticatable.rb +90 -0
- data/lib/devise/models/trackable.rb +36 -0
- data/lib/devise/models/validatable.rb +67 -0
- data/lib/devise/models.rb +129 -0
- data/lib/devise/modules.rb +30 -0
- data/lib/devise/omniauth/config.rb +46 -0
- data/lib/devise/omniauth/url_helpers.rb +19 -0
- data/lib/devise/omniauth.rb +29 -0
- data/lib/devise/orm/active_record.rb +4 -0
- data/lib/devise/orm/mongoid.rb +4 -0
- data/lib/devise/param_filter.rb +42 -0
- data/lib/devise/rails/routes.rb +447 -0
- data/lib/devise/rails/warden_compat.rb +44 -0
- data/lib/devise/rails.rb +55 -0
- data/lib/devise/strategies/authenticatable.rb +177 -0
- data/lib/devise/strategies/base.rb +21 -0
- data/lib/devise/strategies/database_authenticatable.rb +21 -0
- data/lib/devise/strategies/rememberable.rb +56 -0
- data/lib/devise/strategies/token_authenticatable.rb +57 -0
- data/lib/devise/test_helpers.rb +132 -0
- data/lib/devise/time_inflector.rb +15 -0
- data/lib/devise/version.rb +4 -0
- data/lib/devise.rb +445 -0
- data/lib/generators/active_record/devise_generator.rb +80 -0
- data/lib/generators/active_record/templates/migration.rb +20 -0
- data/lib/generators/active_record/templates/migration_existing.rb +27 -0
- data/lib/generators/devise/devise_generator.rb +25 -0
- data/lib/generators/devise/install_generator.rb +25 -0
- data/lib/generators/devise/orm_helpers.rb +33 -0
- data/lib/generators/devise/views_generator.rb +117 -0
- data/lib/generators/mongoid/devise_generator.rb +58 -0
- data/lib/generators/templates/README +35 -0
- data/lib/generators/templates/devise.rb +241 -0
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
- data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +22 -0
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +15 -0
- data/test/controllers/custom_strategy_test.rb +63 -0
- data/test/controllers/helpers_test.rb +254 -0
- data/test/controllers/internal_helpers_test.rb +111 -0
- data/test/controllers/sessions_controller_test.rb +58 -0
- data/test/controllers/url_helpers_test.rb +60 -0
- data/test/delegator_test.rb +20 -0
- data/test/devise_test.rb +73 -0
- data/test/failure_app_test.rb +222 -0
- data/test/generators/active_record_generator_test.rb +76 -0
- data/test/generators/devise_generator_test.rb +40 -0
- data/test/generators/install_generator_test.rb +14 -0
- data/test/generators/mongoid_generator_test.rb +24 -0
- data/test/generators/views_generator_test.rb +53 -0
- data/test/helpers/devise_helper_test.rb +52 -0
- data/test/indifferent_hash.rb +34 -0
- data/test/integration/authenticatable_test.rb +634 -0
- data/test/integration/confirmable_test.rb +299 -0
- data/test/integration/database_authenticatable_test.rb +83 -0
- data/test/integration/http_authenticatable_test.rb +98 -0
- data/test/integration/lockable_test.rb +243 -0
- data/test/integration/omniauthable_test.rb +134 -0
- data/test/integration/recoverable_test.rb +307 -0
- data/test/integration/registerable_test.rb +346 -0
- data/test/integration/rememberable_test.rb +159 -0
- data/test/integration/timeoutable_test.rb +141 -0
- data/test/integration/token_authenticatable_test.rb +162 -0
- data/test/integration/trackable_test.rb +93 -0
- data/test/mailers/confirmation_instructions_test.rb +103 -0
- data/test/mailers/reset_password_instructions_test.rb +84 -0
- data/test/mailers/unlock_instructions_test.rb +78 -0
- data/test/mapping_test.rb +128 -0
- data/test/models/authenticatable_test.rb +8 -0
- data/test/models/confirmable_test.rb +392 -0
- data/test/models/database_authenticatable_test.rb +190 -0
- data/test/models/lockable_test.rb +274 -0
- data/test/models/omniauthable_test.rb +8 -0
- data/test/models/recoverable_test.rb +206 -0
- data/test/models/registerable_test.rb +8 -0
- data/test/models/rememberable_test.rb +175 -0
- data/test/models/serializable_test.rb +49 -0
- data/test/models/timeoutable_test.rb +47 -0
- data/test/models/token_authenticatable_test.rb +56 -0
- data/test/models/trackable_test.rb +14 -0
- data/test/models/validatable_test.rb +117 -0
- data/test/models_test.rb +180 -0
- data/test/omniauth/config_test.rb +58 -0
- data/test/omniauth/url_helpers_test.rb +52 -0
- data/test/orm/active_record.rb +10 -0
- data/test/orm/mongoid.rb +15 -0
- data/test/rails_app/Rakefile +10 -0
- data/test/rails_app/app/active_record/admin.rb +7 -0
- data/test/rails_app/app/active_record/shim.rb +3 -0
- data/test/rails_app/app/active_record/user.rb +7 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +7 -0
- data/test/rails_app/app/controllers/admins_controller.rb +12 -0
- data/test/rails_app/app/controllers/application_controller.rb +9 -0
- data/test/rails_app/app/controllers/home_controller.rb +26 -0
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +3 -0
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +3 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +15 -0
- data/test/rails_app/app/controllers/users_controller.rb +24 -0
- data/test/rails_app/app/helpers/application_helper.rb +4 -0
- data/test/rails_app/app/mailers/users/mailer.rb +9 -0
- data/test/rails_app/app/mongoid/admin.rb +28 -0
- data/test/rails_app/app/mongoid/shim.rb +25 -0
- data/test/rails_app/app/mongoid/user.rb +43 -0
- data/test/rails_app/app/views/admins/index.html.erb +1 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
- data/test/rails_app/app/views/home/index.html.erb +1 -0
- data/test/rails_app/app/views/home/join.html.erb +1 -0
- data/test/rails_app/app/views/home/private.html.erb +1 -0
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +24 -0
- data/test/rails_app/app/views/users/index.html.erb +1 -0
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
- data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
- data/test/rails_app/config/application.rb +42 -0
- data/test/rails_app/config/boot.rb +9 -0
- data/test/rails_app/config/database.yml +18 -0
- data/test/rails_app/config/environment.rb +6 -0
- data/test/rails_app/config/environments/development.rb +19 -0
- data/test/rails_app/config/environments/production.rb +34 -0
- data/test/rails_app/config/environments/test.rb +34 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +8 -0
- data/test/rails_app/config/initializers/devise.rb +179 -0
- data/test/rails_app/config/initializers/inflections.rb +3 -0
- data/test/rails_app/config/initializers/secret_token.rb +3 -0
- data/test/rails_app/config/routes.rb +101 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +75 -0
- data/test/rails_app/db/schema.rb +53 -0
- data/test/rails_app/lib/shared_admin.rb +15 -0
- data/test/rails_app/lib/shared_user.rb +27 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/script/rails +10 -0
- data/test/routes_test.rb +249 -0
- data/test/support/assertions.rb +41 -0
- data/test/support/helpers.rb +92 -0
- data/test/support/integration.rb +93 -0
- data/test/support/locale/en.yml +4 -0
- data/test/support/webrat/integrations/rails.rb +25 -0
- data/test/test_helper.rb +28 -0
- data/test/test_helpers_test.rb +152 -0
- metadata +407 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
<%- if controller_name != 'sessions' %>
|
2
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
3
|
+
<% end -%>
|
4
|
+
|
5
|
+
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
+
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
10
|
+
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
15
|
+
<% end -%>
|
16
|
+
|
17
|
+
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
18
|
+
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
19
|
+
<% end -%>
|
20
|
+
|
21
|
+
<%- if devise_mapping.omniauthable? %>
|
22
|
+
<%- resource_class.omniauth_providers.each do |provider| %>
|
23
|
+
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
|
24
|
+
<% end -%>
|
25
|
+
<% end -%>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h2>Resend unlock instructions</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email, :autofocus => true %></div>
|
8
|
+
|
9
|
+
<div><%= f.submit "Resend unlock instructions" %></div>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
2
|
+
|
3
|
+
en:
|
4
|
+
errors:
|
5
|
+
messages:
|
6
|
+
expired: "has expired, please request a new one"
|
7
|
+
not_found: "not found"
|
8
|
+
already_confirmed: "was already confirmed, please try signing in"
|
9
|
+
not_locked: "was not locked"
|
10
|
+
not_saved:
|
11
|
+
one: "1 error prohibited this %{resource} from being saved:"
|
12
|
+
other: "%{count} errors prohibited this %{resource} from being saved:"
|
13
|
+
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
|
14
|
+
|
15
|
+
devise:
|
16
|
+
failure:
|
17
|
+
already_authenticated: 'You are already signed in.'
|
18
|
+
unauthenticated: 'You need to sign in or sign up before continuing.'
|
19
|
+
unconfirmed: 'You have to confirm your account before continuing.'
|
20
|
+
locked: 'Your account is locked.'
|
21
|
+
invalid: 'Invalid email or password.'
|
22
|
+
invalid_token: 'Invalid authentication token.'
|
23
|
+
timeout: 'Your session expired, please sign in again to continue.'
|
24
|
+
inactive: 'Your account was not activated yet.'
|
25
|
+
sessions:
|
26
|
+
signed_in: 'Signed in successfully.'
|
27
|
+
signed_out: 'Signed out successfully.'
|
28
|
+
passwords:
|
29
|
+
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
30
|
+
updated: 'Your password was changed successfully. You are now signed in.'
|
31
|
+
updated_not_active: 'Your password was changed successfully.'
|
32
|
+
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
33
|
+
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
34
|
+
confirmations:
|
35
|
+
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
36
|
+
send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
|
37
|
+
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
38
|
+
registrations:
|
39
|
+
signed_up: 'Welcome! You have signed up successfully.'
|
40
|
+
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
|
41
|
+
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
|
42
|
+
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
|
43
|
+
updated: 'You updated your account successfully.'
|
44
|
+
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
45
|
+
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
46
|
+
unlocks:
|
47
|
+
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
48
|
+
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
|
49
|
+
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
|
50
|
+
omniauth_callbacks:
|
51
|
+
success: 'Successfully authenticated from %{kind} account.'
|
52
|
+
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
|
53
|
+
mailer:
|
54
|
+
confirmation_instructions:
|
55
|
+
subject: 'Confirmation instructions'
|
56
|
+
reset_password_instructions:
|
57
|
+
subject: 'Reset password instructions'
|
58
|
+
unlock_instructions:
|
59
|
+
subject: 'Unlock Instructions'
|
data/devise.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "devise/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "loyal_devise"
|
7
|
+
s.version = Devise::VERSION.dup
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = "Flexible authentication solution for Rails with Warden"
|
10
|
+
s.email = "contact@plataformatec.com.br"
|
11
|
+
s.homepage = "http://github.com/blogsoso/devise"
|
12
|
+
s.description = "Flexible authentication solution for Rails with Warden"
|
13
|
+
s.authors = ['José Valim', 'Carlos Antônio']
|
14
|
+
|
15
|
+
# s.rubyforge_project = "devise"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency("loyal_warden", "~> 2.0.0")
|
22
|
+
# s.add_dependency("warden", "~> 2.0.0")
|
23
|
+
s.add_dependency("orm_adapter", "~> 0.1")
|
24
|
+
s.add_dependency("bcrypt-ruby", "~> 3.0")
|
25
|
+
# s.add_dependency("railties", "~> 3.1")
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "loyal_devise", :path => ".."
|
4
|
+
|
5
|
+
gem "rails", "~> 3.1.0"
|
6
|
+
gem "omniauth", "~> 1.0.0"
|
7
|
+
gem "omniauth-oauth2", "~> 1.0.0"
|
8
|
+
gem "rdoc"
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem "omniauth-facebook"
|
12
|
+
gem "omniauth-openid", "~> 1.0.1"
|
13
|
+
gem "webrat", "0.7.2", :require => false
|
14
|
+
gem "mocha", :require => false
|
15
|
+
|
16
|
+
platforms :mri_18 do
|
17
|
+
gem "ruby-debug", ">= 0.10.3"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
platforms :jruby do
|
22
|
+
gem "activerecord-jdbc-adapter"
|
23
|
+
gem "activerecord-jdbcsqlite3-adapter"
|
24
|
+
gem "jruby-openssl"
|
25
|
+
end
|
26
|
+
|
27
|
+
platforms :ruby do
|
28
|
+
gem "sqlite3"
|
29
|
+
|
30
|
+
group :mongoid do
|
31
|
+
gem "mongo", "~> 1.3.0"
|
32
|
+
gem "mongoid", "~> 2.0"
|
33
|
+
gem "bson_ext", "~> 1.3.0"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
devise (2.1.0.rc2)
|
5
|
+
bcrypt-ruby (~> 3.0)
|
6
|
+
orm_adapter (~> 0.0.7)
|
7
|
+
railties (~> 3.1)
|
8
|
+
warden (~> 1.1.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionmailer (3.1.4)
|
14
|
+
actionpack (= 3.1.4)
|
15
|
+
mail (~> 2.3.0)
|
16
|
+
actionpack (3.1.4)
|
17
|
+
activemodel (= 3.1.4)
|
18
|
+
activesupport (= 3.1.4)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
erubis (~> 2.7.0)
|
21
|
+
i18n (~> 0.6)
|
22
|
+
rack (~> 1.3.6)
|
23
|
+
rack-cache (~> 1.1)
|
24
|
+
rack-mount (~> 0.8.2)
|
25
|
+
rack-test (~> 0.6.1)
|
26
|
+
sprockets (~> 2.0.3)
|
27
|
+
activemodel (3.1.4)
|
28
|
+
activesupport (= 3.1.4)
|
29
|
+
builder (~> 3.0.0)
|
30
|
+
i18n (~> 0.6)
|
31
|
+
activerecord (3.1.4)
|
32
|
+
activemodel (= 3.1.4)
|
33
|
+
activesupport (= 3.1.4)
|
34
|
+
arel (~> 2.2.3)
|
35
|
+
tzinfo (~> 0.3.29)
|
36
|
+
activeresource (3.1.4)
|
37
|
+
activemodel (= 3.1.4)
|
38
|
+
activesupport (= 3.1.4)
|
39
|
+
activesupport (3.1.4)
|
40
|
+
multi_json (~> 1.0)
|
41
|
+
addressable (2.2.7)
|
42
|
+
arel (2.2.3)
|
43
|
+
bcrypt-ruby (3.0.1)
|
44
|
+
bson (1.5.2)
|
45
|
+
bson_ext (1.3.1)
|
46
|
+
builder (3.0.0)
|
47
|
+
columnize (0.3.6)
|
48
|
+
erubis (2.7.0)
|
49
|
+
faraday (0.7.6)
|
50
|
+
addressable (~> 2.2)
|
51
|
+
multipart-post (~> 1.1)
|
52
|
+
rack (~> 1.1)
|
53
|
+
hashie (1.2.0)
|
54
|
+
hike (1.2.1)
|
55
|
+
i18n (0.6.0)
|
56
|
+
json (1.7.0)
|
57
|
+
linecache (0.46)
|
58
|
+
rbx-require-relative (> 0.0.4)
|
59
|
+
mail (2.3.3)
|
60
|
+
i18n (>= 0.4.0)
|
61
|
+
mime-types (~> 1.16)
|
62
|
+
treetop (~> 1.4.8)
|
63
|
+
metaclass (0.0.1)
|
64
|
+
mime-types (1.18)
|
65
|
+
mocha (0.10.4)
|
66
|
+
metaclass (~> 0.0.1)
|
67
|
+
mongo (1.3.1)
|
68
|
+
bson (>= 1.3.1)
|
69
|
+
mongoid (2.4.4)
|
70
|
+
activemodel (~> 3.1)
|
71
|
+
mongo (~> 1.3)
|
72
|
+
tzinfo (~> 0.3.22)
|
73
|
+
multi_json (1.3.4)
|
74
|
+
multipart-post (1.1.5)
|
75
|
+
nokogiri (1.5.0)
|
76
|
+
oauth2 (0.5.2)
|
77
|
+
faraday (~> 0.7)
|
78
|
+
multi_json (~> 1.0)
|
79
|
+
omniauth (1.0.2)
|
80
|
+
hashie (~> 1.2)
|
81
|
+
rack
|
82
|
+
omniauth-facebook (1.2.0)
|
83
|
+
omniauth-oauth2 (~> 1.0.0)
|
84
|
+
omniauth-oauth2 (1.0.0)
|
85
|
+
oauth2 (~> 0.5.0)
|
86
|
+
omniauth (~> 1.0)
|
87
|
+
omniauth-openid (1.0.1)
|
88
|
+
omniauth (~> 1.0)
|
89
|
+
rack-openid (~> 1.3.1)
|
90
|
+
orm_adapter (0.0.7)
|
91
|
+
polyglot (0.3.3)
|
92
|
+
rack (1.3.6)
|
93
|
+
rack-cache (1.2)
|
94
|
+
rack (>= 0.4)
|
95
|
+
rack-mount (0.8.3)
|
96
|
+
rack (>= 1.0.0)
|
97
|
+
rack-openid (1.3.1)
|
98
|
+
rack (>= 1.1.0)
|
99
|
+
ruby-openid (>= 2.1.8)
|
100
|
+
rack-ssl (1.3.2)
|
101
|
+
rack
|
102
|
+
rack-test (0.6.1)
|
103
|
+
rack (>= 1.0)
|
104
|
+
rails (3.1.4)
|
105
|
+
actionmailer (= 3.1.4)
|
106
|
+
actionpack (= 3.1.4)
|
107
|
+
activerecord (= 3.1.4)
|
108
|
+
activeresource (= 3.1.4)
|
109
|
+
activesupport (= 3.1.4)
|
110
|
+
bundler (~> 1.0)
|
111
|
+
railties (= 3.1.4)
|
112
|
+
railties (3.1.4)
|
113
|
+
actionpack (= 3.1.4)
|
114
|
+
activesupport (= 3.1.4)
|
115
|
+
rack-ssl (~> 1.3.2)
|
116
|
+
rake (>= 0.8.7)
|
117
|
+
rdoc (~> 3.4)
|
118
|
+
thor (~> 0.14.6)
|
119
|
+
rake (0.9.2.2)
|
120
|
+
rbx-require-relative (0.0.5)
|
121
|
+
rdoc (3.12)
|
122
|
+
json (~> 1.4)
|
123
|
+
ruby-debug (0.10.4)
|
124
|
+
columnize (>= 0.1)
|
125
|
+
ruby-debug-base (~> 0.10.4.0)
|
126
|
+
ruby-debug-base (0.10.4)
|
127
|
+
linecache (>= 0.3)
|
128
|
+
ruby-openid (2.1.8)
|
129
|
+
sprockets (2.0.4)
|
130
|
+
hike (~> 1.2)
|
131
|
+
rack (~> 1.0)
|
132
|
+
tilt (~> 1.1, != 1.3.0)
|
133
|
+
sqlite3 (1.3.5)
|
134
|
+
thor (0.14.6)
|
135
|
+
tilt (1.3.3)
|
136
|
+
treetop (1.4.10)
|
137
|
+
polyglot
|
138
|
+
polyglot (>= 0.3.1)
|
139
|
+
tzinfo (0.3.33)
|
140
|
+
warden (1.1.1)
|
141
|
+
rack (>= 1.0)
|
142
|
+
webrat (0.7.2)
|
143
|
+
nokogiri (>= 1.2.0)
|
144
|
+
rack (>= 1.0)
|
145
|
+
rack-test (>= 0.5.3)
|
146
|
+
|
147
|
+
PLATFORMS
|
148
|
+
ruby
|
149
|
+
|
150
|
+
DEPENDENCIES
|
151
|
+
activerecord-jdbc-adapter
|
152
|
+
activerecord-jdbcsqlite3-adapter
|
153
|
+
bson_ext (~> 1.3.0)
|
154
|
+
devise!
|
155
|
+
jruby-openssl
|
156
|
+
mocha
|
157
|
+
mongo (~> 1.3.0)
|
158
|
+
mongoid (~> 2.0)
|
159
|
+
omniauth (~> 1.0.0)
|
160
|
+
omniauth-facebook
|
161
|
+
omniauth-oauth2 (~> 1.0.0)
|
162
|
+
omniauth-openid (~> 1.0.1)
|
163
|
+
rails (~> 3.1.0)
|
164
|
+
rdoc
|
165
|
+
ruby-debug (>= 0.10.3)
|
166
|
+
sqlite3
|
167
|
+
webrat (= 0.7.2)
|
@@ -0,0 +1,273 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Devise
|
3
|
+
module Controllers
|
4
|
+
# Those helpers are convenience methods added to ApplicationController.
|
5
|
+
module Helpers
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
helper_method :warden, :signed_in?, :devise_controller?
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def log_process_action(payload)
|
14
|
+
payload[:status] ||= 401 unless payload[:exception]
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Define authentication filters and accessor helpers based on mappings.
|
20
|
+
# These filters should be used inside the controllers as before_filters,
|
21
|
+
# so you can control the scope of the user who should be signed in to
|
22
|
+
# access that specific controller/action.
|
23
|
+
# Example:
|
24
|
+
#
|
25
|
+
# Roles:
|
26
|
+
# User
|
27
|
+
# Admin
|
28
|
+
#
|
29
|
+
# Generated methods:
|
30
|
+
# authenticate_user! # Signs user in or redirect
|
31
|
+
# authenticate_admin! # Signs admin in or redirect
|
32
|
+
# user_signed_in? # Checks whether there is a user signed in or not
|
33
|
+
# admin_signed_in? # Checks whether there is an admin signed in or not
|
34
|
+
# current_user # Current signed in user
|
35
|
+
# current_admin # Current signed in admin
|
36
|
+
# user_session # Session data available only to the user scope
|
37
|
+
# admin_session # Session data available only to the admin scope
|
38
|
+
#
|
39
|
+
# Use:
|
40
|
+
# before_filter :authenticate_user! # Tell devise to use :user map
|
41
|
+
# before_filter :authenticate_admin! # Tell devise to use :admin map
|
42
|
+
#
|
43
|
+
def self.define_helpers(mapping) #:nodoc:
|
44
|
+
mapping = mapping.name
|
45
|
+
|
46
|
+
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
47
|
+
def authenticate_#{mapping}!(opts={})
|
48
|
+
opts[:scope] = :#{mapping}
|
49
|
+
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
|
50
|
+
end
|
51
|
+
|
52
|
+
def #{mapping}_signed_in?
|
53
|
+
!!current_#{mapping}
|
54
|
+
end
|
55
|
+
|
56
|
+
def current_#{mapping}
|
57
|
+
@current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})
|
58
|
+
end
|
59
|
+
|
60
|
+
def #{mapping}_session
|
61
|
+
current_#{mapping} && warden.session(:#{mapping})
|
62
|
+
end
|
63
|
+
METHODS
|
64
|
+
|
65
|
+
ActiveSupport.on_load(:action_controller) do
|
66
|
+
helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# The main accessor for the warden proxy instance
|
71
|
+
def warden
|
72
|
+
request.env['warden']
|
73
|
+
end
|
74
|
+
|
75
|
+
# Return true if it's a devise_controller. false to all controllers unless
|
76
|
+
# the controllers defined inside devise. Useful if you want to apply a before
|
77
|
+
# filter to all controllers, except the ones in devise:
|
78
|
+
#
|
79
|
+
# before_filter :my_filter, :unless => :devise_controller?
|
80
|
+
def devise_controller?
|
81
|
+
is_a?(DeviseController)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Tell warden that params authentication is allowed for that specific page.
|
85
|
+
def allow_params_authentication!
|
86
|
+
request.env["devise.allow_params_authentication"] = true
|
87
|
+
end
|
88
|
+
|
89
|
+
# Return true if the given scope is signed in session. If no scope given, return
|
90
|
+
# true if any scope is signed in. Does not run authentication hooks.
|
91
|
+
def signed_in?(scope=nil)
|
92
|
+
[ scope || Devise.mappings.keys ].flatten.any? do |_scope|
|
93
|
+
warden.authenticate?(:scope => _scope)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Sign in a user that already was authenticated. This helper is useful for logging
|
98
|
+
# users in after sign up.
|
99
|
+
#
|
100
|
+
# All options given to sign_in is passed forward to the set_user method in warden.
|
101
|
+
# The only exception is the :bypass option, which bypass warden callbacks and stores
|
102
|
+
# the user straight in session. This option is useful in cases the user is already
|
103
|
+
# signed in, but we want to refresh the credentials in session.
|
104
|
+
#
|
105
|
+
# Examples:
|
106
|
+
#
|
107
|
+
# sign_in :user, @user # sign_in(scope, resource)
|
108
|
+
# sign_in @user # sign_in(resource)
|
109
|
+
# sign_in @user, :event => :authentication # sign_in(resource, options)
|
110
|
+
# sign_in @user, :bypass => true # sign_in(resource, options)
|
111
|
+
#
|
112
|
+
def sign_in(resource_or_scope, *args)
|
113
|
+
options = args.extract_options!
|
114
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
115
|
+
resource = args.last || resource_or_scope
|
116
|
+
|
117
|
+
expire_session_data_after_sign_in!
|
118
|
+
|
119
|
+
if options[:bypass]
|
120
|
+
warden.session_serializer.store(resource, scope)
|
121
|
+
elsif warden.user(scope) == resource && !options.delete(:force)
|
122
|
+
# Do nothing. User already signed in and we are not forcing it.
|
123
|
+
true
|
124
|
+
else
|
125
|
+
warden.set_user(resource, options.merge!(:scope => scope))
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Sign out a given user or scope. This helper is useful for signing out a user
|
130
|
+
# after deleting accounts. Returns true if there was a logout and false if there
|
131
|
+
# is no user logged in on the referred scope
|
132
|
+
#
|
133
|
+
# Examples:
|
134
|
+
#
|
135
|
+
# sign_out :user # sign_out(scope)
|
136
|
+
# sign_out @user # sign_out(resource)
|
137
|
+
#
|
138
|
+
def sign_out(resource_or_scope=nil)
|
139
|
+
return sign_out_all_scopes unless resource_or_scope
|
140
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
141
|
+
user = warden.user(:scope => scope, :run_callbacks => false) # If there is no user
|
142
|
+
|
143
|
+
warden.raw_session.inspect # Without this inspect here. The session does not clear.
|
144
|
+
warden.logout(scope)
|
145
|
+
warden.clear_strategies_cache!(:scope => scope)
|
146
|
+
instance_variable_set(:"@current_#{scope}", nil)
|
147
|
+
|
148
|
+
!!user
|
149
|
+
end
|
150
|
+
|
151
|
+
# Sign out all active users or scopes. This helper is useful for signing out all roles
|
152
|
+
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
|
153
|
+
# and false if there was no user logged in on all scopes.
|
154
|
+
def sign_out_all_scopes(lock=true)
|
155
|
+
users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
|
156
|
+
|
157
|
+
warden.raw_session.inspect
|
158
|
+
warden.logout
|
159
|
+
expire_devise_cached_variables!
|
160
|
+
warden.clear_strategies_cache!
|
161
|
+
warden.lock! if lock
|
162
|
+
|
163
|
+
users.any?
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns and delete the url stored in the session for the given scope. Useful
|
167
|
+
# for giving redirect backs after sign up:
|
168
|
+
#
|
169
|
+
# Example:
|
170
|
+
#
|
171
|
+
# redirect_to stored_location_for(:user) || root_path
|
172
|
+
#
|
173
|
+
def stored_location_for(resource_or_scope)
|
174
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
175
|
+
session.delete("#{scope}_return_to")
|
176
|
+
end
|
177
|
+
|
178
|
+
# The scope root url to be used when he's signed in. By default, it first
|
179
|
+
# tries to find a resource_root_path, otherwise it uses the root_path.
|
180
|
+
def signed_in_root_path(resource_or_scope)
|
181
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
182
|
+
home_path = "#{scope}_root_path"
|
183
|
+
if respond_to?(home_path, true)
|
184
|
+
send(home_path)
|
185
|
+
elsif respond_to?(:root_path)
|
186
|
+
root_path
|
187
|
+
else
|
188
|
+
"/"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# The default url to be used after signing in. This is used by all Devise
|
193
|
+
# controllers and you can overwrite it in your ApplicationController to
|
194
|
+
# provide a custom hook for a custom resource.
|
195
|
+
#
|
196
|
+
# By default, it first tries to find a valid resource_return_to key in the
|
197
|
+
# session, then it fallbacks to resource_root_path, otherwise it uses the
|
198
|
+
# root path. For a user scope, you can define the default url in
|
199
|
+
# the following way:
|
200
|
+
#
|
201
|
+
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
202
|
+
#
|
203
|
+
# map.namespace :user do |user|
|
204
|
+
# user.root :controller => 'users' # creates user_root_path
|
205
|
+
# end
|
206
|
+
#
|
207
|
+
# If the resource root path is not defined, root_path is used. However,
|
208
|
+
# if this default is not enough, you can customize it, for example:
|
209
|
+
#
|
210
|
+
# def after_sign_in_path_for(resource)
|
211
|
+
# stored_location_for(resource) ||
|
212
|
+
# if resource.is_a?(User) && resource.can_publish?
|
213
|
+
# publisher_url
|
214
|
+
# else
|
215
|
+
# super
|
216
|
+
# end
|
217
|
+
# end
|
218
|
+
#
|
219
|
+
def after_sign_in_path_for(resource_or_scope)
|
220
|
+
stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)
|
221
|
+
end
|
222
|
+
|
223
|
+
# Method used by sessions controller to sign out a user. You can overwrite
|
224
|
+
# it in your ApplicationController to provide a custom hook for a custom
|
225
|
+
# scope. Notice that differently from +after_sign_in_path_for+ this method
|
226
|
+
# receives a symbol with the scope, and not the resource.
|
227
|
+
#
|
228
|
+
# By default it is the root_path.
|
229
|
+
def after_sign_out_path_for(resource_or_scope)
|
230
|
+
respond_to?(:root_path) ? root_path : "/"
|
231
|
+
end
|
232
|
+
|
233
|
+
# Sign in a user and tries to redirect first to the stored location and
|
234
|
+
# then to the url specified by after_sign_in_path_for. It accepts the same
|
235
|
+
# parameters as the sign_in method.
|
236
|
+
def sign_in_and_redirect(resource_or_scope, *args)
|
237
|
+
options = args.extract_options!
|
238
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
239
|
+
resource = args.last || resource_or_scope
|
240
|
+
sign_in(scope, resource, options)
|
241
|
+
redirect_to after_sign_in_path_for(resource)
|
242
|
+
end
|
243
|
+
|
244
|
+
def expire_session_data_after_sign_in!
|
245
|
+
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
246
|
+
end
|
247
|
+
|
248
|
+
# Sign out a user and tries to redirect to the url specified by
|
249
|
+
# after_sign_out_path_for.
|
250
|
+
def sign_out_and_redirect(resource_or_scope)
|
251
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
252
|
+
redirect_path = after_sign_out_path_for(scope)
|
253
|
+
Devise.sign_out_all_scopes ? sign_out : sign_out(scope)
|
254
|
+
redirect_to redirect_path
|
255
|
+
end
|
256
|
+
|
257
|
+
# Overwrite Rails' handle unverified request to sign out all scopes,
|
258
|
+
# clear run strategies and remove cached variables.
|
259
|
+
def handle_unverified_request
|
260
|
+
sign_out_all_scopes(false)
|
261
|
+
request.env["devise.skip_storage"] = true
|
262
|
+
expire_devise_cached_variables!
|
263
|
+
super # call the default behaviour which resets the session
|
264
|
+
end
|
265
|
+
|
266
|
+
private
|
267
|
+
|
268
|
+
def expire_devise_cached_variables!
|
269
|
+
Devise.mappings.each { |_,m| instance_variable_set("@current_#{m.name}", nil) }
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Devise
|
3
|
+
module Controllers
|
4
|
+
# A module that may be optionally included in a controller in order
|
5
|
+
# to provide remember me behavior.
|
6
|
+
module Rememberable
|
7
|
+
# Return default cookie values retrieved from session options.
|
8
|
+
def self.cookie_values
|
9
|
+
Rails.configuration.session_options.slice(:path, :domain, :secure)
|
10
|
+
end
|
11
|
+
|
12
|
+
# A small warden proxy so we can remember and forget uses from hooks.
|
13
|
+
class Proxy #:nodoc:
|
14
|
+
include Devise::Controllers::Rememberable
|
15
|
+
|
16
|
+
delegate :cookies, :env, :to => :@warden
|
17
|
+
|
18
|
+
def initialize(warden)
|
19
|
+
@warden = warden
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Remembers the given resource by setting up a cookie
|
24
|
+
def remember_me(resource)
|
25
|
+
scope = Devise::Mapping.find_scope!(resource)
|
26
|
+
resource.remember_me!(resource.extend_remember_period)
|
27
|
+
cookies.signed["remember_#{scope}_token"] = remember_cookie_values(resource)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Forgets the given resource by deleting a cookie
|
31
|
+
def forget_me(resource)
|
32
|
+
scope = Devise::Mapping.find_scope!(resource)
|
33
|
+
resource.forget_me!
|
34
|
+
cookies.delete("remember_#{scope}_token", forget_cookie_values(resource))
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def forget_cookie_values(resource)
|
40
|
+
Devise::Controllers::Rememberable.cookie_values.merge!(resource.rememberable_options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def remember_cookie_values(resource)
|
44
|
+
options = { :httponly => true }
|
45
|
+
options.merge!(forget_cookie_values(resource))
|
46
|
+
options.merge!(
|
47
|
+
:value => resource.class.serialize_into_cookie(resource),
|
48
|
+
:expires => resource.remember_expires_at
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Devise
|
3
|
+
module Controllers
|
4
|
+
module ScopedViews
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def scoped_views?
|
9
|
+
defined?(@scoped_views) ? @scoped_views : Devise.scoped_views
|
10
|
+
end
|
11
|
+
|
12
|
+
def scoped_views=(value)
|
13
|
+
@scoped_views = value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|