devise 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +13 -1
- data/README.rdoc +6 -22
- data/Rakefile +1 -1
- data/app/controllers/confirmations_controller.rb +1 -2
- data/app/controllers/passwords_controller.rb +1 -2
- data/app/controllers/sessions_controller.rb +2 -3
- data/lib/devise.rb +3 -0
- data/lib/devise/controllers/filters.rb +47 -0
- data/lib/devise/controllers/helpers.rb +4 -24
- data/lib/devise/mapping.rb +1 -1
- data/lib/devise/models/authenticatable.rb +19 -5
- data/lib/devise/rails/routes.rb +8 -2
- data/lib/devise/version.rb +1 -1
- data/test/controllers/filters_test.rb +36 -0
- data/test/devise_test.rb +4 -0
- data/test/models/authenticatable_test.rb +12 -2
- data/test/rails_app/app/models/account.rb +4 -0
- data/test/rails_app/app/models/admin.rb +4 -0
- data/test/rails_app/config/routes.rb +1 -1
- data/test/test_helper.rb +3 -3
- metadata +38 -38
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 0.5.4
|
2
|
+
|
3
|
+
* deprecations
|
4
|
+
* Deprecate :singular in devise_for and use :scope instead
|
5
|
+
|
6
|
+
* enhancements
|
7
|
+
* [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
|
8
|
+
overwriten in ApplicationController
|
9
|
+
* Create sign_in_and_redirect and sign_out_and_redirect helpers
|
10
|
+
* Warden::Manager.default_scope is automatically configured to the first given scope
|
11
|
+
* Allow overwriting find for authentication method
|
12
|
+
|
1
13
|
== 0.5.3
|
2
14
|
|
3
15
|
* bug fix
|
@@ -48,7 +60,7 @@
|
|
48
60
|
* skip_before_filter added in Devise controllers
|
49
61
|
* Use home_or_root_path on require_no_authentication as well
|
50
62
|
* Added devise_controller?, useful to select or reject filters in ApplicationController
|
51
|
-
* Allow :path_prefix to be given to devise_for
|
63
|
+
* Allow :path_prefix to be given to devise_for
|
52
64
|
* Allow default_url_options to be configured through devise (:path_prefix => "/:locale" is now supported)
|
53
65
|
|
54
66
|
== 0.4.1
|
data/README.rdoc
CHANGED
@@ -103,33 +103,15 @@ The next step after setting up your model is to configure your routes for devise
|
|
103
103
|
|
104
104
|
map.devise_for :users
|
105
105
|
|
106
|
-
This is going to look inside you User model and create
|
106
|
+
This is going to look inside you User model and create a set of needed routes (you can see them by running `rake routes`).
|
107
107
|
|
108
|
-
|
109
|
-
new_user_session GET /users/sign_in {:controller=>"sessions", :action=>"new"}
|
110
|
-
user_session POST /users/sign_in {:controller=>"sessions", :action=>"create"}
|
111
|
-
destroy_user_session GET /users/sign_out {:controller=>"sessions", :action=>"destroy"}
|
112
|
-
|
113
|
-
# Password routes for Recoverable, if User model has :recoverable configured
|
114
|
-
new_user_password GET /users/password/new(.:format) {:controller=>"passwords", :action=>"new"}
|
115
|
-
edit_user_password GET /users/password/edit(.:format) {:controller=>"passwords", :action=>"edit"}
|
116
|
-
user_password PUT /users/password(.:format) {:controller=>"passwords", :action=>"update"}
|
117
|
-
POST /users/password(.:format) {:controller=>"passwords", :action=>"create"}
|
118
|
-
|
119
|
-
# Confirmation routes for Confirmable, if User model has :confirmable configured
|
120
|
-
new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"confirmations", :action=>"new"}
|
121
|
-
user_confirmation GET /users/confirmation(.:format) {:controller=>"confirmations", :action=>"show"}
|
122
|
-
POST /users/confirmation(.:format) {:controller=>"confirmations", :action=>"create"}
|
123
|
-
|
124
|
-
You can run the routes rake task to verify what routes are being created by devise.
|
125
|
-
|
126
|
-
There are also some options available for configuring your routes, as :class_name (to set the class for that route), :as and :path_names, where the last two have the same meaning as in routes. The available :path_names are:
|
108
|
+
There are also some options available for configuring your routes, as :class_name (to set the class for that route), :as and :path_names, where the last two have the same meaning as in common routes. The available :path_names are:
|
127
109
|
|
128
110
|
map.devise_for :users, :as => "usuarios", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification' }
|
129
111
|
|
130
112
|
Be sure to check devise_for documentation for detailed description.
|
131
113
|
|
132
|
-
== Controller filters
|
114
|
+
== Controller filters and helpers
|
133
115
|
|
134
116
|
Devise is gonna create some helpers to use inside your controllers and views. To setup a controller that needs user authentication, just add this before_filter:
|
135
117
|
|
@@ -151,7 +133,9 @@ After signing in a user, confirming it's account or updating it's password, devi
|
|
151
133
|
|
152
134
|
map.root :controller => 'home'
|
153
135
|
|
154
|
-
You also
|
136
|
+
You can also overwrite after_sign_in_path_for and after_sign_out_path_for to customize better your redirect hooks.
|
137
|
+
|
138
|
+
Finally, if you are using confirmable or recoverable, you also need to setup default url options for the mailer. Here's is the configuration for development:
|
155
139
|
|
156
140
|
DeviseMailer.sender = "no-reply@yourapp.com"
|
157
141
|
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ begin
|
|
36
36
|
s.description = "Flexible authentication solution for Rails with Warden"
|
37
37
|
s.authors = ['José Valim', 'Carlos Antônio']
|
38
38
|
s.files = FileList["[A-Z]*", "{app,config,generators,lib}/**/*", "init.rb"]
|
39
|
-
s.add_dependency("warden", "~> 0.6.
|
39
|
+
s.add_dependency("warden", "~> 0.6.3")
|
40
40
|
end
|
41
41
|
|
42
42
|
Jeweler::GemcutterTasks.new
|
@@ -23,9 +23,8 @@ class ConfirmationsController < ApplicationController
|
|
23
23
|
self.resource = resource_class.confirm!(:confirmation_token => params[:confirmation_token])
|
24
24
|
|
25
25
|
if resource.errors.empty?
|
26
|
-
sign_in(resource_name, resource)
|
27
26
|
set_flash_message :success, :confirmed
|
28
|
-
|
27
|
+
sign_in_and_redirect(resource_name, resource)
|
29
28
|
else
|
30
29
|
render :new
|
31
30
|
end
|
@@ -31,9 +31,8 @@ class PasswordsController < ApplicationController
|
|
31
31
|
self.resource = resource_class.reset_password!(params[resource_name])
|
32
32
|
|
33
33
|
if resource.errors.empty?
|
34
|
-
sign_in(resource_name, resource)
|
35
34
|
set_flash_message :success, :updated
|
36
|
-
|
35
|
+
sign_in_and_redirect(resource_name, resource)
|
37
36
|
else
|
38
37
|
render :edit
|
39
38
|
end
|
@@ -15,7 +15,7 @@ class SessionsController < ApplicationController
|
|
15
15
|
def create
|
16
16
|
if authenticate(resource_name)
|
17
17
|
set_flash_message :success, :signed_in
|
18
|
-
|
18
|
+
sign_in_and_redirect(resource_name)
|
19
19
|
else
|
20
20
|
set_now_flash_message :failure, warden.message || :invalid
|
21
21
|
build_resource
|
@@ -26,8 +26,7 @@ class SessionsController < ApplicationController
|
|
26
26
|
# GET /resource/sign_out
|
27
27
|
def destroy
|
28
28
|
set_flash_message :success, :signed_out if signed_in?(resource_name)
|
29
|
-
|
30
|
-
redirect_to root_path
|
29
|
+
sign_out_and_redirect(resource_name)
|
31
30
|
end
|
32
31
|
|
33
32
|
end
|
data/lib/devise.rb
CHANGED
@@ -138,6 +138,9 @@ rescue
|
|
138
138
|
require 'warden'
|
139
139
|
end
|
140
140
|
|
141
|
+
# Set the default_scope to nil, so it's overwritten when the first route is declared.
|
142
|
+
Warden::Manager.default_scope = nil
|
143
|
+
|
141
144
|
require 'devise/strategies/base'
|
142
145
|
require 'devise/serializers/base'
|
143
146
|
|
@@ -90,6 +90,53 @@ module Devise
|
|
90
90
|
session.delete(:"#{scope}.return_to")
|
91
91
|
end
|
92
92
|
|
93
|
+
# The default url to be used after signing in. This is used by all Devise
|
94
|
+
# controllers and you can overwrite it in your ApplicationController to
|
95
|
+
# provide a custom hook for a custom resource.
|
96
|
+
#
|
97
|
+
# By default, it first tries to find a resource_root_path, otherwise it
|
98
|
+
# uses the root path. For a user scope, you can define the default url in
|
99
|
+
# the following way:
|
100
|
+
#
|
101
|
+
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
102
|
+
#
|
103
|
+
# map.resources :users do |users|
|
104
|
+
# users.root # creates user_root_path
|
105
|
+
# end
|
106
|
+
#
|
107
|
+
# If none of these are defined, root_path is used.
|
108
|
+
def after_sign_in_path_for(resource_or_scope)
|
109
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
110
|
+
home_path = :"#{scope}_root_path"
|
111
|
+
respond_to?(home_path, true) ? send(home_path) : root_path
|
112
|
+
end
|
113
|
+
|
114
|
+
# The default to be used after signing out. This is used by all Devise
|
115
|
+
# controllers and you can overwrite it in your ApplicationController to
|
116
|
+
# provide a custom hook for a custom resource.
|
117
|
+
#
|
118
|
+
# By default is the root_path.
|
119
|
+
def after_sign_out_path_for(resource_or_scope)
|
120
|
+
root_path
|
121
|
+
end
|
122
|
+
|
123
|
+
# Sign in an user and tries to redirect first to the stored location and
|
124
|
+
# then to the url specified by after_sign_in_path_for.
|
125
|
+
#
|
126
|
+
# If just a symbol is given, consider that the user was already signed in
|
127
|
+
# through other means and just perform the redirection.
|
128
|
+
def sign_in_and_redirect(*args)
|
129
|
+
sign_in(*args) unless args.one? && args.first.is_a?(Symbol)
|
130
|
+
redirect_to stored_location_for(args.first) || after_sign_in_path_for(args.first)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Sign out an user and tries to redirect to the url specified by
|
134
|
+
# after_sign_out_path_for.
|
135
|
+
def sign_out_and_redirect(resource_or_scope)
|
136
|
+
sign_out(resource_or_scope)
|
137
|
+
redirect_to after_sign_out_path_for(resource_or_scope)
|
138
|
+
end
|
139
|
+
|
93
140
|
# Define authentication filters and accessor helpers based on mappings.
|
94
141
|
# These filters should be used inside the controllers as before_filters,
|
95
142
|
# so you can control the scope of the user who should be signed in to
|
@@ -9,8 +9,8 @@ module Devise
|
|
9
9
|
base.class_eval do
|
10
10
|
unloadable
|
11
11
|
|
12
|
-
helper_method :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
13
|
-
hide_action :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
12
|
+
helper_method :resource, :scope_name, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
13
|
+
hide_action :resource, :scope_name, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
14
14
|
|
15
15
|
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
|
16
16
|
before_filter :is_devise_resource?
|
@@ -26,6 +26,7 @@ module Devise
|
|
26
26
|
def resource_name
|
27
27
|
devise_mapping.name
|
28
28
|
end
|
29
|
+
alias :scope_name :resource_name
|
29
30
|
|
30
31
|
# Proxy to devise map class
|
31
32
|
def resource_class
|
@@ -44,27 +45,6 @@ module Devise
|
|
44
45
|
|
45
46
|
protected
|
46
47
|
|
47
|
-
# Redirects to stored uri before signing in or the default path and clear
|
48
|
-
# return to.
|
49
|
-
def redirect_back_or_to(default)
|
50
|
-
redirect_to(stored_location_for(resource_name) || default)
|
51
|
-
end
|
52
|
-
|
53
|
-
# Checks for the existence of the resource root path. If it exists,
|
54
|
-
# returns it, otherwise returns the default root_path.
|
55
|
-
# Used after authenticating a user, confirming it's account or updating
|
56
|
-
# it's password, so we are able to redirect to scoped root paths.
|
57
|
-
# Examples (for a user scope):
|
58
|
-
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
59
|
-
#
|
60
|
-
# map.namespace :users do |users|
|
61
|
-
# users.root # creates user_root_path
|
62
|
-
# end
|
63
|
-
def home_or_root_path
|
64
|
-
home_path = :"#{resource_name}_root_path"
|
65
|
-
respond_to?(home_path, true) ? send(home_path) : root_path
|
66
|
-
end
|
67
|
-
|
68
48
|
# Checks whether it's a devise mapped resource or not.
|
69
49
|
def is_devise_resource? #:nodoc:
|
70
50
|
raise ActionController::UnknownAction unless devise_mapping && devise_mapping.allows?(controller_name)
|
@@ -88,7 +68,7 @@ module Devise
|
|
88
68
|
# Example:
|
89
69
|
# before_filter :require_no_authentication, :only => :new
|
90
70
|
def require_no_authentication
|
91
|
-
redirect_to
|
71
|
+
redirect_to after_sign_in_path_for(resource_name) if warden.authenticated?(resource_name)
|
92
72
|
end
|
93
73
|
|
94
74
|
# Sets the flash message with :key, using I18n. By default you are able
|
data/lib/devise/mapping.rb
CHANGED
@@ -60,7 +60,7 @@ module Devise
|
|
60
60
|
def initialize(name, options) #:nodoc:
|
61
61
|
@as = (options.delete(:as) || name).to_sym
|
62
62
|
@klass = (options.delete(:class_name) || name.to_s.classify).to_s
|
63
|
-
@name = (options.delete(:
|
63
|
+
@name = (options.delete(:scope) || name.to_s.singularize).to_sym
|
64
64
|
@path_names = options.delete(:path_names) || {}
|
65
65
|
@path_prefix = options.delete(:path_prefix) || ""
|
66
66
|
@path_prefix << "/" unless @path_prefix[-1] == ?/
|
@@ -60,16 +60,30 @@ module Devise
|
|
60
60
|
end
|
61
61
|
|
62
62
|
module ClassMethods
|
63
|
-
# Authenticate a user based on
|
64
|
-
# authenticated user if it's valid or nil.
|
65
|
-
#
|
63
|
+
# Authenticate a user based on configured attribute keys. Returns the
|
64
|
+
# authenticated user if it's valid or nil. Attributes are by default
|
65
|
+
# :email and :password, the latter is always required.
|
66
66
|
def authenticate(attributes={})
|
67
67
|
return unless authentication_keys.all? { |k| attributes[k].present? }
|
68
68
|
conditions = attributes.slice(*authentication_keys)
|
69
|
-
authenticatable =
|
69
|
+
authenticatable = find_for_authentication(conditions)
|
70
70
|
authenticatable if authenticatable.try(:valid_password?, attributes[:password])
|
71
71
|
end
|
72
72
|
|
73
|
+
# Find first record based on conditions given (ie by the sign in form).
|
74
|
+
# Overwrite to add customized conditions, create a join, or maybe use a
|
75
|
+
# namedscope to filter records while authenticating.
|
76
|
+
# Example:
|
77
|
+
#
|
78
|
+
# def self.find_for_authentication(conditions={})
|
79
|
+
# conditions[:active] = true
|
80
|
+
# find(:first, :conditions => conditions)
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
def find_for_authentication(conditions)
|
84
|
+
find(:first, :conditions => conditions)
|
85
|
+
end
|
86
|
+
|
73
87
|
# Attempt to find a user by it's email. If not user is found, returns a
|
74
88
|
# new user with an email not found error.
|
75
89
|
def find_or_initialize_with_error_by_email(email)
|
@@ -88,7 +102,7 @@ module Devise
|
|
88
102
|
# Hook to serialize user from session. Overwrite if you want.
|
89
103
|
def serialize_from_session(keys)
|
90
104
|
klass, id = keys
|
91
|
-
raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
|
105
|
+
raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
|
92
106
|
klass.find_by_id(id)
|
93
107
|
end
|
94
108
|
end
|
data/lib/devise/rails/routes.rb
CHANGED
@@ -52,9 +52,9 @@ module ActionController::Routing
|
|
52
52
|
#
|
53
53
|
# map.devise_for :users, :as => 'accounts'
|
54
54
|
#
|
55
|
-
# * :
|
55
|
+
# * :scope => setup the scope name. This is used as the instance variable name in controller, as the name in routes and the scope given to warden. Defaults to the singular of the given name:
|
56
56
|
#
|
57
|
-
# map.devise_for :users, :
|
57
|
+
# map.devise_for :users, :scope => :account
|
58
58
|
#
|
59
59
|
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :password and :confirmation.
|
60
60
|
#
|
@@ -77,9 +77,15 @@ module ActionController::Routing
|
|
77
77
|
def devise_for(*resources)
|
78
78
|
options = resources.extract_options!
|
79
79
|
|
80
|
+
if singular = options.delete(:singular)
|
81
|
+
ActiveSupport::Deprecation.warn ":singular is deprecated in devise_for, use :scope instead."
|
82
|
+
options[:scope] = singular
|
83
|
+
end
|
84
|
+
|
80
85
|
resources.map!(&:to_sym)
|
81
86
|
resources.each do |resource|
|
82
87
|
mapping = Devise::Mapping.new(resource, options.dup)
|
88
|
+
Warden::Manager.default_scope ||= mapping.name
|
83
89
|
Devise.mappings[mapping.name] = mapping
|
84
90
|
|
85
91
|
route_options = mapping.route_options.merge(:path_prefix => mapping.raw_path, :name_prefix => "#{mapping.name}_")
|
data/lib/devise/version.rb
CHANGED
@@ -121,6 +121,42 @@ class ControllerAuthenticableTest < ActionController::TestCase
|
|
121
121
|
assert_nil @controller.session[:"user.return_to"]
|
122
122
|
end
|
123
123
|
|
124
|
+
test 'after sign in path defaults to root path if none by was specified for the given scope' do
|
125
|
+
assert_equal root_path, @controller.after_sign_in_path_for(:user)
|
126
|
+
end
|
127
|
+
|
128
|
+
test 'after sign in path defaults to the scoped root path' do
|
129
|
+
assert_equal admin_root_path, @controller.after_sign_in_path_for(:admin)
|
130
|
+
end
|
131
|
+
|
132
|
+
test 'after sign out path defaults to the root path' do
|
133
|
+
assert_equal root_path, @controller.after_sign_out_path_for(:admin)
|
134
|
+
assert_equal root_path, @controller.after_sign_out_path_for(:user)
|
135
|
+
end
|
136
|
+
|
137
|
+
test 'sign in and redirect uses the stored location' do
|
138
|
+
user = User.new
|
139
|
+
@controller.session[:"user.return_to"] = "/foo.bar"
|
140
|
+
@mock_warden.expects(:set_user).with(user, :scope => :user).returns(true)
|
141
|
+
@controller.expects(:redirect_to).with("/foo.bar")
|
142
|
+
@controller.sign_in_and_redirect(user)
|
143
|
+
end
|
144
|
+
|
145
|
+
test 'sign in and redirect uses the configured after sign in path' do
|
146
|
+
admin = Admin.new
|
147
|
+
@mock_warden.expects(:set_user).with(admin, :scope => :admin).returns(true)
|
148
|
+
@controller.expects(:redirect_to).with(admin_root_path)
|
149
|
+
@controller.sign_in_and_redirect(admin)
|
150
|
+
end
|
151
|
+
|
152
|
+
test 'sign out and redirect uses the configured after sign out path' do
|
153
|
+
@mock_warden.expects(:user).with(:admin).returns(true)
|
154
|
+
@mock_warden.expects(:logout).with(:admin).returns(true)
|
155
|
+
@controller.expects(:redirect_to).with(admin_root_path)
|
156
|
+
@controller.instance_eval "def after_sign_out_path_for(resource); admin_root_path; end"
|
157
|
+
@controller.sign_out_and_redirect(:admin)
|
158
|
+
end
|
159
|
+
|
124
160
|
test 'is not a devise controller' do
|
125
161
|
assert_not @controller.devise_controller?
|
126
162
|
end
|
data/test/devise_test.rb
CHANGED
@@ -66,6 +66,10 @@ class DeviseTest < ActiveSupport::TestCase
|
|
66
66
|
assert manager.silence_missing_strategies
|
67
67
|
end
|
68
68
|
|
69
|
+
test 'warden default scope is set' do
|
70
|
+
assert_equal :user, Warden::Manager.default_scope
|
71
|
+
end
|
72
|
+
|
69
73
|
test 'warden manager user configuration through a block' do
|
70
74
|
begin
|
71
75
|
@executed = false
|
@@ -92,9 +92,9 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
|
92
92
|
Devise.stretches = default_stretches
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
test 'should respect encryptor configuration' do
|
97
|
-
begin
|
97
|
+
begin
|
98
98
|
Devise.encryptor = ::Devise::Encryptors::Sha512
|
99
99
|
user = create_user
|
100
100
|
assert_equal user.encrypted_password, encrypt_password(user, User.pepper, User.stretches, ::Devise::Encryptors::Sha512)
|
@@ -136,6 +136,16 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
+
test 'should allow overwriting find for authentication conditions' do
|
140
|
+
admin = Admin.create!(valid_attributes)
|
141
|
+
assert_not_nil Admin.authenticate(:email => admin.email, :password => admin.password)
|
142
|
+
end
|
143
|
+
|
144
|
+
test 'should never authenticate an account' do
|
145
|
+
account = Account.create!(valid_attributes)
|
146
|
+
assert_nil Account.authenticate(:email => account.email, :password => account.password)
|
147
|
+
end
|
148
|
+
|
139
149
|
test 'should serialize user into session' do
|
140
150
|
user = create_user
|
141
151
|
assert_equal [User, user.id], User.serialize_into_session(user)
|
@@ -4,7 +4,7 @@ ActionController::Routing::Routes.draw do |map|
|
|
4
4
|
map.devise_for :account, :path_names => {
|
5
5
|
:sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification'
|
6
6
|
}
|
7
|
-
map.devise_for :organizers, :
|
7
|
+
map.devise_for :organizers, :scope => 'manager',
|
8
8
|
:path_prefix => '/:locale',
|
9
9
|
:requirements => { :extra => 'value' }
|
10
10
|
|
data/test/test_helper.rb
CHANGED
@@ -15,12 +15,12 @@ ActiveRecord::Base.logger = Logger.new(nil)
|
|
15
15
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
16
16
|
|
17
17
|
ActiveRecord::Schema.define(:version => 1) do
|
18
|
-
[:users, :admins].each do |table|
|
18
|
+
[:users, :admins, :accounts].each do |table|
|
19
19
|
create_table table do |t|
|
20
20
|
t.authenticatable :null => table == :admins
|
21
|
-
t.string :username if table == :users
|
22
21
|
|
23
|
-
if table
|
22
|
+
if table != :admin
|
23
|
+
t.string :username
|
24
24
|
t.confirmable
|
25
25
|
t.recoverable
|
26
26
|
t.rememberable
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-19 00:00:00 -02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.6.
|
24
|
+
version: 0.6.3
|
25
25
|
version:
|
26
26
|
description: Flexible authentication solution for Rails with Warden
|
27
27
|
email: contact@plataformatec.com.br
|
@@ -120,45 +120,45 @@ signing_key:
|
|
120
120
|
specification_version: 3
|
121
121
|
summary: Flexible authentication solution for Rails with Warden
|
122
122
|
test_files:
|
123
|
-
- test/rails_app/config/boot.rb
|
124
|
-
- test/rails_app/config/routes.rb
|
125
|
-
- test/rails_app/config/environments/development.rb
|
126
|
-
- test/rails_app/config/environments/production.rb
|
127
|
-
- test/rails_app/config/environments/test.rb
|
128
|
-
- test/rails_app/config/environment.rb
|
129
|
-
- test/rails_app/config/initializers/session_store.rb
|
130
|
-
- test/rails_app/config/initializers/new_rails_defaults.rb
|
131
|
-
- test/rails_app/app/controllers/users_controller.rb
|
132
|
-
- test/rails_app/app/controllers/application_controller.rb
|
133
|
-
- test/rails_app/app/controllers/admins_controller.rb
|
134
|
-
- test/rails_app/app/controllers/home_controller.rb
|
135
|
-
- test/rails_app/app/helpers/application_helper.rb
|
136
|
-
- test/rails_app/app/models/admin.rb
|
137
|
-
- test/rails_app/app/models/organizer.rb
|
138
|
-
- test/rails_app/app/models/account.rb
|
139
|
-
- test/rails_app/app/models/user.rb
|
140
|
-
- test/controllers/url_helpers_test.rb
|
141
|
-
- test/controllers/helpers_test.rb
|
142
123
|
- test/controllers/filters_test.rb
|
143
|
-
- test/
|
144
|
-
- test/
|
145
|
-
- test/integration/rememberable_test.rb
|
146
|
-
- test/integration/recoverable_test.rb
|
147
|
-
- test/integration/confirmable_test.rb
|
148
|
-
- test/mailers/confirmation_instructions_test.rb
|
149
|
-
- test/mailers/reset_password_instructions_test.rb
|
150
|
-
- test/models/authenticatable_test.rb
|
151
|
-
- test/models/rememberable_test.rb
|
152
|
-
- test/models/recoverable_test.rb
|
124
|
+
- test/controllers/helpers_test.rb
|
125
|
+
- test/controllers/url_helpers_test.rb
|
153
126
|
- test/models/validatable_test.rb
|
127
|
+
- test/models/rememberable_test.rb
|
154
128
|
- test/models/confirmable_test.rb
|
129
|
+
- test/models/recoverable_test.rb
|
130
|
+
- test/models/authenticatable_test.rb
|
131
|
+
- test/integration/rememberable_test.rb
|
132
|
+
- test/integration/confirmable_test.rb
|
133
|
+
- test/integration/recoverable_test.rb
|
134
|
+
- test/integration/authenticatable_test.rb
|
135
|
+
- test/test_helper.rb
|
136
|
+
- test/test_helpers_test.rb
|
155
137
|
- test/encryptors_test.rb
|
138
|
+
- test/mailers/reset_password_instructions_test.rb
|
139
|
+
- test/mailers/confirmation_instructions_test.rb
|
140
|
+
- test/routes_test.rb
|
141
|
+
- test/devise_test.rb
|
142
|
+
- test/failure_app_test.rb
|
143
|
+
- test/rails_app/app/controllers/admins_controller.rb
|
144
|
+
- test/rails_app/app/controllers/home_controller.rb
|
145
|
+
- test/rails_app/app/controllers/users_controller.rb
|
146
|
+
- test/rails_app/app/controllers/application_controller.rb
|
147
|
+
- test/rails_app/app/models/account.rb
|
148
|
+
- test/rails_app/app/models/user.rb
|
149
|
+
- test/rails_app/app/models/admin.rb
|
150
|
+
- test/rails_app/app/models/organizer.rb
|
151
|
+
- test/rails_app/app/helpers/application_helper.rb
|
152
|
+
- test/rails_app/config/boot.rb
|
153
|
+
- test/rails_app/config/environments/production.rb
|
154
|
+
- test/rails_app/config/environments/development.rb
|
155
|
+
- test/rails_app/config/environments/test.rb
|
156
|
+
- test/rails_app/config/initializers/new_rails_defaults.rb
|
157
|
+
- test/rails_app/config/initializers/session_store.rb
|
158
|
+
- test/rails_app/config/routes.rb
|
159
|
+
- test/rails_app/config/environment.rb
|
160
|
+
- test/mapping_test.rb
|
156
161
|
- test/support/model_tests_helper.rb
|
157
162
|
- test/support/assertions_helper.rb
|
158
163
|
- test/support/integration_tests_helper.rb
|
159
|
-
- test/
|
160
|
-
- test/devise_test.rb
|
161
|
-
- test/routes_test.rb
|
162
|
-
- test/test_helper.rb
|
163
|
-
- test/test_helpers_test.rb
|
164
|
-
- test/mapping_test.rb
|
164
|
+
- test/models_test.rb
|