ramon-devise 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +109 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +243 -0
- data/Rakefile +45 -0
- data/TODO +8 -0
- data/app/controllers/confirmations_controller.rb +33 -0
- data/app/controllers/passwords_controller.rb +41 -0
- data/app/controllers/sessions_controller.rb +33 -0
- data/app/models/devise_mailer.rb +53 -0
- data/app/views/confirmations/new.html.erb +16 -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/passwords/edit.html.erb +20 -0
- data/app/views/passwords/new.html.erb +16 -0
- data/app/views/sessions/new.html.erb +23 -0
- data/generators/devise/USAGE +5 -0
- data/generators/devise/devise_generator.rb +25 -0
- data/generators/devise/lib/route_devise.rb +32 -0
- data/generators/devise/templates/README +22 -0
- data/generators/devise/templates/migration.rb +20 -0
- data/generators/devise/templates/model.rb +5 -0
- data/generators/devise_install/USAGE +3 -0
- data/generators/devise_install/devise_install_generator.rb +9 -0
- data/generators/devise_install/templates/devise.rb +40 -0
- data/generators/devise_views/USAGE +3 -0
- data/generators/devise_views/devise_views_generator.rb +24 -0
- data/init.rb +2 -0
- data/lib/devise.rb +79 -0
- data/lib/devise/controllers/filters.rb +111 -0
- data/lib/devise/controllers/helpers.rb +130 -0
- data/lib/devise/controllers/url_helpers.rb +49 -0
- data/lib/devise/failure.rb +38 -0
- data/lib/devise/hooks/confirmable.rb +11 -0
- data/lib/devise/hooks/rememberable.rb +27 -0
- data/lib/devise/locales/en.yml +18 -0
- data/lib/devise/mapping.rb +120 -0
- data/lib/devise/migrations.rb +51 -0
- data/lib/devise/models.rb +105 -0
- data/lib/devise/models/authenticatable.rb +97 -0
- data/lib/devise/models/confirmable.rb +156 -0
- data/lib/devise/models/recoverable.rb +88 -0
- data/lib/devise/models/rememberable.rb +95 -0
- data/lib/devise/models/validatable.rb +36 -0
- data/lib/devise/rails.rb +17 -0
- data/lib/devise/rails/routes.rb +109 -0
- data/lib/devise/rails/warden_compat.rb +26 -0
- data/lib/devise/strategies/authenticatable.rb +46 -0
- data/lib/devise/strategies/base.rb +24 -0
- data/lib/devise/strategies/rememberable.rb +35 -0
- data/lib/devise/version.rb +3 -0
- data/lib/devise/warden.rb +24 -0
- data/test/controllers/filters_test.rb +103 -0
- data/test/controllers/helpers_test.rb +55 -0
- data/test/controllers/url_helpers_test.rb +47 -0
- data/test/devise_test.rb +72 -0
- data/test/failure_test.rb +34 -0
- data/test/integration/authenticatable_test.rb +187 -0
- data/test/integration/confirmable_test.rb +89 -0
- data/test/integration/recoverable_test.rb +131 -0
- data/test/integration/rememberable_test.rb +65 -0
- data/test/mailers/confirmation_instructions_test.rb +59 -0
- data/test/mailers/reset_password_instructions_test.rb +62 -0
- data/test/mapping_test.rb +101 -0
- data/test/models/authenticatable_test.rb +118 -0
- data/test/models/confirmable_test.rb +237 -0
- data/test/models/recoverable_test.rb +141 -0
- data/test/models/rememberable_test.rb +130 -0
- data/test/models/validatable_test.rb +99 -0
- data/test/models_test.rb +111 -0
- data/test/rails_app/app/controllers/admins_controller.rb +6 -0
- data/test/rails_app/app/controllers/application_controller.rb +10 -0
- data/test/rails_app/app/controllers/home_controller.rb +4 -0
- data/test/rails_app/app/controllers/users_controller.rb +7 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/models/account.rb +3 -0
- data/test/rails_app/app/models/admin.rb +3 -0
- data/test/rails_app/app/models/organizer.rb +3 -0
- data/test/rails_app/app/models/user.rb +3 -0
- data/test/rails_app/config/boot.rb +110 -0
- data/test/rails_app/config/environment.rb +41 -0
- data/test/rails_app/config/environments/development.rb +17 -0
- data/test/rails_app/config/environments/production.rb +28 -0
- data/test/rails_app/config/environments/test.rb +28 -0
- data/test/rails_app/config/initializers/new_rails_defaults.rb +21 -0
- data/test/rails_app/config/initializers/session_store.rb +15 -0
- data/test/rails_app/config/routes.rb +18 -0
- data/test/routes_test.rb +79 -0
- data/test/support/assertions_helper.rb +22 -0
- data/test/support/integration_tests_helper.rb +66 -0
- data/test/support/model_tests_helper.rb +51 -0
- data/test/test_helper.rb +40 -0
- metadata +154 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
class PasswordsController < ApplicationController
|
2
|
+
include Devise::Controllers::Helpers
|
3
|
+
|
4
|
+
before_filter :require_no_authentication
|
5
|
+
|
6
|
+
# GET /resource/password/new
|
7
|
+
def new
|
8
|
+
build_resource
|
9
|
+
end
|
10
|
+
|
11
|
+
# POST /resource/password
|
12
|
+
def create
|
13
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
14
|
+
|
15
|
+
if resource.errors.empty?
|
16
|
+
set_flash_message :success, :send_instructions
|
17
|
+
redirect_to new_session_path(resource_name)
|
18
|
+
else
|
19
|
+
render :new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET /resource/password/edit?perishable_token=abcdef
|
24
|
+
def edit
|
25
|
+
self.resource = resource_class.new
|
26
|
+
resource.reset_password_token = params[:reset_password_token]
|
27
|
+
end
|
28
|
+
|
29
|
+
# PUT /resource/password
|
30
|
+
def update
|
31
|
+
self.resource = resource_class.reset_password!(params[resource_name])
|
32
|
+
|
33
|
+
if resource.errors.empty?
|
34
|
+
sign_in(resource_name, resource)
|
35
|
+
set_flash_message :success, :updated
|
36
|
+
redirect_to home_or_root_path
|
37
|
+
else
|
38
|
+
render :edit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class SessionsController < ApplicationController
|
2
|
+
include Devise::Controllers::Helpers
|
3
|
+
|
4
|
+
before_filter :require_no_authentication, :only => [ :new, :create ]
|
5
|
+
|
6
|
+
# GET /resource/sign_in
|
7
|
+
def new
|
8
|
+
Devise::FLASH_MESSAGES.each do |message, type|
|
9
|
+
set_now_flash_message type, message if params.key?(message)
|
10
|
+
end
|
11
|
+
build_resource
|
12
|
+
end
|
13
|
+
|
14
|
+
# POST /resource/sign_in
|
15
|
+
def create
|
16
|
+
if authenticate(resource_name)
|
17
|
+
set_flash_message :success, :signed_in
|
18
|
+
redirect_back_or_to home_or_root_path
|
19
|
+
else
|
20
|
+
set_now_flash_message :failure, :invalid
|
21
|
+
build_resource
|
22
|
+
render :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /resource/sign_out
|
27
|
+
def destroy
|
28
|
+
set_flash_message :success, :signed_out if signed_in?(resource_name)
|
29
|
+
sign_out(resource_name)
|
30
|
+
redirect_to root_path
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class DeviseMailer < ::ActionMailer::Base
|
2
|
+
|
3
|
+
# Sets who is sending the e-mail
|
4
|
+
def self.sender=(value)
|
5
|
+
@@sender = value
|
6
|
+
end
|
7
|
+
|
8
|
+
# Reads who is sending the e-mail
|
9
|
+
def self.sender
|
10
|
+
@@sender
|
11
|
+
end
|
12
|
+
self.sender = nil
|
13
|
+
|
14
|
+
# Deliver confirmation instructions when the user is created or its email is
|
15
|
+
# updated, and also when confirmation is manually requested
|
16
|
+
def confirmation_instructions(record)
|
17
|
+
setup_mail(record, :confirmation_instructions)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Deliver reset password instructions when manually requested
|
21
|
+
def reset_password_instructions(record)
|
22
|
+
setup_mail(record, :reset_password_instructions)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Configure default email options
|
28
|
+
def setup_mail(record, key)
|
29
|
+
mapping = Devise.mappings.values.find { |m| m.to == record.class }
|
30
|
+
raise "Invalid devise resource #{record}" unless mapping
|
31
|
+
|
32
|
+
subject translate(mapping, key)
|
33
|
+
from self.class.sender
|
34
|
+
recipients record.email
|
35
|
+
sent_on Time.now
|
36
|
+
content_type 'text/html'
|
37
|
+
body mapping.name => record, :resource => record
|
38
|
+
end
|
39
|
+
|
40
|
+
# Setup subject namespaced by model. It means you're able to setup your
|
41
|
+
# messages using specific resource scope, or provide a default one.
|
42
|
+
# Example (i18n locale file):
|
43
|
+
#
|
44
|
+
# en:
|
45
|
+
# devise:
|
46
|
+
# mailer:
|
47
|
+
# confirmation_instructions: '...'
|
48
|
+
# user:
|
49
|
+
# confirmation_instructions: '...'
|
50
|
+
def translate(mapping, key)
|
51
|
+
I18n.t(:"#{mapping.name}.#{key}", :scope => [:devise, :mailer], :default => key)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2>Resend confirmation instructions</h2>
|
2
|
+
|
3
|
+
<% form_for resource_name, resource, :url => confirmation_path(resource_name) do |f| %>
|
4
|
+
<%= f.error_messages %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %></p>
|
7
|
+
<p><%= f.text_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.submit "Resend confirmation instructions" %></p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
13
|
+
|
14
|
+
<%- if devise_mapping.recoverable? %>
|
15
|
+
<%= link_to "Forgot password?", new_password_path(resource_name) %><br />
|
16
|
+
<% end -%>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Hello <%= @resource.email %>!
|
2
|
+
|
3
|
+
Someone has requested a link to change your password, and you can do this through the link below.
|
4
|
+
|
5
|
+
<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
|
6
|
+
|
7
|
+
If you didn't request this, please ignore this email.
|
8
|
+
Your password won't change until you access the link above and create a new one.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<h2>Change your password</h2>
|
2
|
+
|
3
|
+
<% form_for resource_name, resource, :url => password_path(resource_name), :html => { :method => :put } do |f| %>
|
4
|
+
<%= f.error_messages %>
|
5
|
+
<%= f.hidden_field :reset_password_token %>
|
6
|
+
|
7
|
+
<p><%= f.label :password %></p>
|
8
|
+
<p><%= f.password_field :password %></p>
|
9
|
+
|
10
|
+
<p><%= f.label :password_confirmation %></p>
|
11
|
+
<p><%= f.password_field :password_confirmation %></p>
|
12
|
+
|
13
|
+
<p><%= f.submit "Change my password" %></p>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
17
|
+
|
18
|
+
<%- if devise_mapping.confirmable? %>
|
19
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
20
|
+
<% end -%>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2>Forgot your password?</h2>
|
2
|
+
|
3
|
+
<% form_for resource_name, resource, :url => password_path(resource_name) do |f| %>
|
4
|
+
<%= f.error_messages %>
|
5
|
+
|
6
|
+
<p><%= f.label :email %></p>
|
7
|
+
<p><%= f.text_field :email %></p>
|
8
|
+
|
9
|
+
<p><%= f.submit "Send me reset password instructions" %></p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
13
|
+
|
14
|
+
<%- if devise_mapping.confirmable? %>
|
15
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
16
|
+
<% end -%>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<h2>Sign in</h2>
|
2
|
+
|
3
|
+
<% form_for resource_name, resource, :url => session_path(resource_name) do |f| -%>
|
4
|
+
<p><%= f.label :email %></p>
|
5
|
+
<p><%= f.text_field :email %></p>
|
6
|
+
|
7
|
+
<p><%= f.label :password %></p>
|
8
|
+
<p><%= f.password_field :password %></p>
|
9
|
+
|
10
|
+
<% if devise_mapping.rememberable? -%>
|
11
|
+
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
<p><%= f.submit "Sign in" %></p>
|
15
|
+
<% end -%>
|
16
|
+
|
17
|
+
<%- if devise_mapping.recoverable? %>
|
18
|
+
<%= link_to "Forgot password?", new_password_path(resource_name) %><br />
|
19
|
+
<% end -%>
|
20
|
+
|
21
|
+
<%- if devise_mapping.confirmable? %>
|
22
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
23
|
+
<% end -%>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/lib/route_devise.rb")
|
2
|
+
|
3
|
+
class DeviseGenerator < Rails::Generator::NamedBase
|
4
|
+
|
5
|
+
def manifest
|
6
|
+
record do |m|
|
7
|
+
# Check for class naming collisions.
|
8
|
+
m.class_collisions(class_name)
|
9
|
+
|
10
|
+
# Model
|
11
|
+
m.directory(File.join('app', 'models', class_path))
|
12
|
+
m.template 'model.rb', File.join('app', 'models', "#{file_path}.rb")
|
13
|
+
|
14
|
+
# Migration
|
15
|
+
m.migration_template 'migration.rb', 'db/migrate', :migration_file_name => "devise_create_#{table_name}"
|
16
|
+
|
17
|
+
# Routing
|
18
|
+
m.route_devise table_name
|
19
|
+
|
20
|
+
# Readme
|
21
|
+
m.readme "README"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generator
|
3
|
+
module Commands
|
4
|
+
class Create < Base
|
5
|
+
|
6
|
+
# Create devise route. Based on route_resources
|
7
|
+
def route_devise(*resources)
|
8
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
9
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
10
|
+
|
11
|
+
logger.route "map.devise_for #{resource_list}"
|
12
|
+
unless options[:pretend]
|
13
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
14
|
+
"#{match}\n map.devise_for #{resource_list}\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Destroy < RewindBase
|
21
|
+
|
22
|
+
# Destroy devise route. Based on route_resources
|
23
|
+
def route_devise(*resources)
|
24
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
25
|
+
look_for = "\n map.devise_for #{resource_list}\n"
|
26
|
+
logger.route "map.devise_for #{resource_list}"
|
27
|
+
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
================================================================================
|
3
|
+
|
4
|
+
Some setup you must do manually if you haven't yet:
|
5
|
+
|
6
|
+
1. Setup defaut url options for your specific environment. Here is an example of development environment:
|
7
|
+
|
8
|
+
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
9
|
+
|
10
|
+
It's a Rails required configuration. In production it must be the actual host your application is deployed to.
|
11
|
+
|
12
|
+
2. Setup default sender for mails. In config/environment.rb:
|
13
|
+
|
14
|
+
DeviseMailer.sender = "test@example.com"
|
15
|
+
|
16
|
+
You can also configure this value by running script/generate devise_install and setting config.mailer_sender,
|
17
|
+
|
18
|
+
3. Ensure you have defined root_url to *something* in your config/routes.rb:
|
19
|
+
|
20
|
+
map.root :controller => 'home'
|
21
|
+
|
22
|
+
================================================================================
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table(:<%= table_name %>) do |t|
|
4
|
+
t.authenticatable
|
5
|
+
t.confirmable
|
6
|
+
t.recoverable
|
7
|
+
t.rememberable
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :<%= table_name %>, :email, :unique => true
|
13
|
+
add_index :<%= table_name %>, :confirmation_token, :unique => true
|
14
|
+
add_index :<%= table_name %>, :reset_password_token, :unique => true
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :<%= table_name %>
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
2
|
+
# four configuration values can also be set straight in your models.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# Invoke `rake secret` and use the printed value to setup a pepper to generate
|
5
|
+
# the encrypted password. By default no pepper is used.
|
6
|
+
# config.pepper = "rake secret output"
|
7
|
+
|
8
|
+
# Configure how many times you want the password is reencrypted. Default is 10.
|
9
|
+
# config.stretches = 10
|
10
|
+
|
11
|
+
# The time you want give to your user to confirm his account. During this time
|
12
|
+
# he will be able to access your application without confirming. Default is nil.
|
13
|
+
# config.confirm_within = 2.days
|
14
|
+
|
15
|
+
# The time the user will be remembered without asking for credentials again.
|
16
|
+
# config.remember_for = 2.weeks
|
17
|
+
|
18
|
+
# Configure the e-mail address which will be shown in DeviseMailer.
|
19
|
+
# config.mailer_sender = "foo.bar@yourapp.com"
|
20
|
+
|
21
|
+
# If you want to use other strategies, that are not (yet) supported by Devise,
|
22
|
+
# you can configure them inside the config.warden block. The example below
|
23
|
+
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
|
24
|
+
#
|
25
|
+
# config.warden do |manager|
|
26
|
+
# manager.oauth(:twitter) do |twitter|
|
27
|
+
# twitter.consumer_secret = <YOUR CONSUMER SECRET>
|
28
|
+
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
29
|
+
# twitter.options :site => 'http://twitter.com'
|
30
|
+
# end
|
31
|
+
# manager.default_strategies.unshift :twitter_oauth
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Configure default_url_options if you are using dynamic segments in :path_prefix
|
35
|
+
# for devise_for.
|
36
|
+
#
|
37
|
+
# config.default_url_options do
|
38
|
+
# { :locale => I18n.locale }
|
39
|
+
# end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class DeviseViewsGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
def initialize(*args)
|
4
|
+
super
|
5
|
+
@source_root = options[:source] || File.join(spec.path, '..', '..')
|
6
|
+
end
|
7
|
+
|
8
|
+
def manifest
|
9
|
+
record do |m|
|
10
|
+
m.directory "app/views"
|
11
|
+
|
12
|
+
Dir[File.join(@source_root, "app", "views", "**/*.erb")].each do |file|
|
13
|
+
file = file.gsub(@source_root, "")[1..-1]
|
14
|
+
|
15
|
+
m.directory File.dirname(file)
|
16
|
+
m.file file, file
|
17
|
+
end
|
18
|
+
|
19
|
+
m.directory "config/locales"
|
20
|
+
m.file "lib/devise/locales/en.yml", "config/locales/devise.en.yml"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/init.rb
ADDED
data/lib/devise.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Devise
|
2
|
+
ALL = [:authenticatable, :confirmable, :recoverable, :rememberable, :validatable].freeze
|
3
|
+
|
4
|
+
# Maps controller names to devise modules
|
5
|
+
CONTROLLERS = {
|
6
|
+
:sessions => :authenticatable,
|
7
|
+
:passwords => :recoverable,
|
8
|
+
:confirmations => :confirmable
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
STRATEGIES = [:rememberable, :authenticatable].freeze
|
12
|
+
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
|
13
|
+
|
14
|
+
# Maps the messages types that comes from warden to a flash type.
|
15
|
+
FLASH_MESSAGES = {
|
16
|
+
:unauthenticated => :success,
|
17
|
+
:unconfirmed => :failure
|
18
|
+
}
|
19
|
+
|
20
|
+
# Models configuration
|
21
|
+
mattr_accessor :pepper, :stretches, :remember_for, :confirm_within
|
22
|
+
|
23
|
+
# Mappings
|
24
|
+
mattr_accessor :mappings
|
25
|
+
self.mappings = {}
|
26
|
+
|
27
|
+
class << self
|
28
|
+
# Default way to setup Devise. Run script/generate devise_install to create
|
29
|
+
# a fresh initializer with all configuration values.
|
30
|
+
def setup
|
31
|
+
yield self
|
32
|
+
end
|
33
|
+
|
34
|
+
def mail_sender=(value) #:nodoc:
|
35
|
+
ActiveSupport::Deprecation.warn "Devise.mail_sender= is deprecated, use Devise.mailer_sender instead"
|
36
|
+
DeviseMailer.sender = value
|
37
|
+
end
|
38
|
+
|
39
|
+
# Sets the sender in DeviseMailer.
|
40
|
+
def mailer_sender=(value)
|
41
|
+
DeviseMailer.sender = value
|
42
|
+
end
|
43
|
+
alias :sender= :mailer_sender=
|
44
|
+
|
45
|
+
# Sets warden configuration using a block that will be invoked on warden
|
46
|
+
# initialization.
|
47
|
+
#
|
48
|
+
# Devise.initialize do |config|
|
49
|
+
# config.confirm_within = 2.days
|
50
|
+
#
|
51
|
+
# config.warden do |manager|
|
52
|
+
# # Configure warden to use other strategies, like oauth.
|
53
|
+
# manager.oauth(:twitter)
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
def warden(&block)
|
57
|
+
@warden_config = block
|
58
|
+
end
|
59
|
+
|
60
|
+
# Configure default url options to be used within Devise and ActionController.
|
61
|
+
def default_url_options(&block)
|
62
|
+
Devise::Mapping.metaclass.send :define_method, :default_url_options, &block
|
63
|
+
end
|
64
|
+
|
65
|
+
# A method used internally to setup warden manager from the Rails initialize
|
66
|
+
# block.
|
67
|
+
def configure_warden_manager(manager) #:nodoc:
|
68
|
+
manager.default_strategies *Devise::STRATEGIES
|
69
|
+
manager.failure_app = Devise::Failure
|
70
|
+
manager.silence_missing_strategies!
|
71
|
+
|
72
|
+
# If the user provided a warden hook, call it now.
|
73
|
+
@warden_config.try :call, manager
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
require 'devise/warden'
|
79
|
+
require 'devise/rails'
|