radiant-users-extension 0.0.5 → 2.1.0.beta
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/.gitignore +1 -0
- data/MIT-LICENCE +19 -0
- data/README.md +69 -16
- data/Rakefile +25 -11
- data/app/helpers/admin/users_helper.rb +5 -0
- data/app/models/administrator.rb +3 -0
- data/app/models/designer.rb +3 -0
- data/app/models/user.rb +82 -0
- data/app/models/visitor.rb +3 -0
- data/app/views/admin/users/_fields.html.haml +49 -0
- data/app/views/admin/users/_form.html.haml +6 -0
- data/app/views/admin/users/remove.html.haml +16 -0
- data/app/views/confirmations/new.html.haml +13 -0
- data/app/views/devise_mailer/confirmation_instructions.html.haml +9 -0
- data/app/views/devise_mailer/reset_password_instructions.html.haml +15 -0
- data/app/views/devise_mailer/unlock_instructions.html.haml +12 -0
- data/app/views/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/passwords/edit.html.haml +17 -0
- data/app/views/passwords/new.html.haml +14 -0
- data/app/views/registrations/edit.html.haml +32 -0
- data/app/views/registrations/new.html.haml +30 -0
- data/app/views/sessions/new.html.haml +27 -0
- data/app/views/shared/_links.html.haml +42 -0
- data/app/views/shared/_version.html.haml +5 -0
- data/app/views/unlocks/new.html.haml +9 -0
- data/config/initializers/devise.rb +12 -0
- data/config/initializers/radiant_config.rb +3 -0
- data/config/initializers/radiant_devise_encryptor.rb +10 -0
- data/config/locales/devise.en.yml +35 -0
- data/config/locales/en.yml +8 -0
- data/config/routes.rb +11 -6
- data/db/migrate/20110105024337_change_users_to_devise.rb +94 -0
- data/db/migrate/20110105150917_add_class_name_field.rb +9 -0
- data/db/migrate/20110107032850_move_permissions_to_class.rb +30 -0
- data/db/migrate/20110118103247_change_admin_to_administrator.rb +18 -0
- data/features/support/env.rb +1 -1
- data/lib/login_system.rb +81 -0
- data/lib/radiant-users-extension.rb +2 -1
- data/lib/radiant-users-extension/version.rb +3 -0
- data/lib/tasks/users_extension_tasks.rake +3 -2
- data/lib/users/controllers/admin/resource_controller.rb +15 -0
- data/lib/users/controllers/admin/welcome_controller.rb +19 -0
- data/lib/users/controllers/application_controller.rb +25 -0
- data/lib/users/controllers/devise/confirmations_controller.rb +17 -0
- data/lib/users/controllers/devise/passwords_controller.rb +17 -0
- data/lib/users/controllers/devise/registrations_controller.rb +17 -0
- data/lib/users/controllers/devise/sessions_controller.rb +17 -0
- data/lib/users/controllers/single_form_body_styles.rb +27 -0
- data/lib/users/controllers/site_controller.rb +13 -0
- data/lib/users/lib/devise/controllers/internal_helpers.rb +31 -0
- data/lib/users/tags/core.rb +11 -13
- data/lib/users/tags/helper.rb +13 -0
- data/lib/users/tags/helpers.rb +1 -7
- data/radiant-users-extension.gemspec +73 -13
- data/spec/datasets/devise_users_dataset.rb +56 -0
- data/spec/models/user_spec.rb +125 -13
- data/spec/spec.opts +3 -4
- data/spec/spec_helper.rb +15 -4
- data/spec/tags/core_spec.rb +128 -0
- data/users_extension.rb +27 -9
- metadata +105 -21
- data/db/migrate/20100311014641_add_api_key_to_users.rb +0 -14
- data/db/migrate/20100311021835_add_access_to_user.rb +0 -9
- data/lib/users/lib/login_system.rb +0 -48
@@ -1,14 +0,0 @@
|
|
1
|
-
class AddApiKeyToUsers < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
add_column :users, :api_key, :string, :limit => 40, :default => ''
|
4
|
-
|
5
|
-
User.all.each do |u|
|
6
|
-
u.generate_api_key
|
7
|
-
u.save
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.down
|
12
|
-
remove_column :users, :api_key
|
13
|
-
end
|
14
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Users
|
2
|
-
module Lib
|
3
|
-
module LoginSystem
|
4
|
-
|
5
|
-
def self.included(base)
|
6
|
-
base.class_eval do
|
7
|
-
protected
|
8
|
-
alias_method :authorize_radiant, :authorize
|
9
|
-
alias_method :current_user_radiant, :current_user
|
10
|
-
|
11
|
-
def authorize
|
12
|
-
if user_has_backend_access?
|
13
|
-
authorize_radiant
|
14
|
-
else
|
15
|
-
path = Radiant::Config["scoped.#{current_user.access}.welcome"]
|
16
|
-
path = "/#{path}".gsub('//','/')
|
17
|
-
|
18
|
-
respond_to do |format|
|
19
|
-
format.any(:html, :xml, :json) { redirect_to(path) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def user_has_backend_access?
|
25
|
-
current_user.access.blank?
|
26
|
-
end
|
27
|
-
|
28
|
-
def current_user
|
29
|
-
@current_user ||= (current_user_radiant || login_from_api_key)
|
30
|
-
end
|
31
|
-
|
32
|
-
def login_from_api_key
|
33
|
-
result = nil
|
34
|
-
if params[:api_key].present?
|
35
|
-
result = User.find_by_api_key(params[:api_key])
|
36
|
-
else
|
37
|
-
authenticate_with_http_basic do |api_key,_|
|
38
|
-
result = User.find_by_api_key(api_key)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
result
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|