radiant-users-extension 0.0.5 → 2.1.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- 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 +1,2 @@
|
|
1
|
-
|
1
|
+
module RadiantUsersExtension
|
2
|
+
end
|
@@ -3,14 +3,15 @@ namespace :radiant do
|
|
3
3
|
namespace :users do
|
4
4
|
|
5
5
|
desc "Runs the migration of the Users extension"
|
6
|
-
task :migrate =>
|
6
|
+
task :migrate => :environment do
|
7
7
|
require 'radiant/extension_migrator'
|
8
8
|
if ENV["VERSION"]
|
9
9
|
UsersExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
10
11
|
else
|
11
12
|
UsersExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
12
14
|
end
|
13
|
-
Rake::Task['db:schema:dump'].invoke
|
14
15
|
end
|
15
16
|
|
16
17
|
desc "Copies public assets of the Users to the instance public/ directory."
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
module ApplicationController
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def default_admin_path
|
11
|
+
default_user_path || root_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_user_path
|
15
|
+
return false unless user_signed_in?
|
16
|
+
return '/admin/pages' if user_has_access_to_action?(:index)
|
17
|
+
Radiant::Config["defaults.path.#{current_user.class_name.downcase}"]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
module Devise
|
4
|
+
module ConfirmationsController
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
include Users::Controllers::SingleFormBodyStyles
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
skip_before_filter :authenticate_user, :only => [ :new, :create, :show ]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
module Devise
|
4
|
+
module PasswordsController
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
include Users::Controllers::SingleFormBodyStyles
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
skip_before_filter :authenticate_user, :only => [ :new, :create, :edit, :update ]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
module Devise
|
4
|
+
module RegistrationsController
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
include Users::Controllers::SingleFormBodyStyles
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
skip_before_filter :authenticate_user, :only => [ :new, :create ]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
module Devise
|
4
|
+
module SessionsController
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
include Users::Controllers::SingleFormBodyStyles
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
skip_before_filter :authenticate_user, :only => [ :new, :create, :destroy ]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Users
|
2
|
+
module Controllers
|
3
|
+
module SingleFormBodyStyles
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
|
8
|
+
def set_standard_body_style
|
9
|
+
@body_classes ||= []
|
10
|
+
@body_classes.concat(%w(single_form))
|
11
|
+
end
|
12
|
+
|
13
|
+
def after_sign_out_path_for(resource)
|
14
|
+
new_user_session_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def after_sign_in_path_for(resource)
|
18
|
+
# TODO class based redirect
|
19
|
+
default_admin_path
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Users
|
2
|
+
module Lib
|
3
|
+
module Devise
|
4
|
+
module Controllers
|
5
|
+
module InternalHelpers
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
|
11
|
+
def set_flash_message(key, kind, now=false)
|
12
|
+
type = [:invalid, :alert, :unauthenticated].include?(kind) ? :error : kind
|
13
|
+
type = [:error].include?(type) ? type : :notice
|
14
|
+
|
15
|
+
flash[type] = I18n.t(:"#{kind}",
|
16
|
+
:scope => [:devise, controller_name.to_sym], :default => kind)
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_sign_in_path_for(resource)
|
20
|
+
default_admin_path
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/lib/users/tags/core.rb
CHANGED
@@ -2,42 +2,40 @@ module Users
|
|
2
2
|
module Tags
|
3
3
|
module Core
|
4
4
|
include Radiant::Taggable
|
5
|
-
|
5
|
+
|
6
6
|
tag 'user' do |tag|
|
7
7
|
return if tag.locals.page.cache?
|
8
8
|
|
9
|
-
tag.locals.user =
|
9
|
+
tag.locals.user = Helper.current_user(tag)
|
10
10
|
|
11
11
|
tag.expand
|
12
12
|
end
|
13
13
|
|
14
|
+
desc %{ will expand if the user is logged in }
|
14
15
|
tag 'user:if_user' do |tag|
|
15
16
|
tag.expand if tag.locals.user.present?
|
16
17
|
end
|
17
18
|
|
19
|
+
desc %{ will expand if the user is not logged in}
|
18
20
|
tag 'user:unless_user' do |tag|
|
19
21
|
tag.expand unless tag.locals.user.present?
|
20
22
|
end
|
21
23
|
|
24
|
+
desc %{ will expand if the user can access radiant }
|
22
25
|
tag 'user:if_authorized' do |tag|
|
23
|
-
tag.expand
|
26
|
+
tag.expand if tag.locals.user.authorized?
|
24
27
|
end
|
25
28
|
|
29
|
+
desc %{ will expand if the user can not access radiant }
|
26
30
|
tag 'user:unless_authorized' do |tag|
|
27
|
-
tag.expand
|
28
|
-
end
|
29
|
-
|
30
|
-
tag 'user:if_admin' do |tag|
|
31
|
-
tag.expand if tag.locals.user.admin
|
31
|
+
tag.expand unless tag.locals.user.authorized?
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
tag.expand unless tag.locals.user.admin
|
36
|
-
end
|
37
|
-
|
38
|
-
[:name, :first_name, :last_name, :login, :email, :access].each do |symbol|
|
34
|
+
[:name, :login, :username, :email, :class_name].each do |symbol|
|
39
35
|
desc %{ outputs the #{symbol} of the current user }
|
40
36
|
tag "user:#{symbol}" do |tag|
|
37
|
+
return unless tag.locals.user.present?
|
38
|
+
|
41
39
|
tag.locals.user.send(symbol)
|
42
40
|
end
|
43
41
|
end
|
data/lib/users/tags/helpers.rb
CHANGED
@@ -2,15 +2,9 @@ module Users
|
|
2
2
|
module Tags
|
3
3
|
class Helpers
|
4
4
|
class << self
|
5
|
-
include ActionView::Helpers::NumberHelper
|
6
5
|
|
7
6
|
def current_user(tag)
|
8
|
-
|
9
|
-
user_id = tag.locals.page.request.session['user_id']
|
10
|
-
User.find(user_id)
|
11
|
-
rescue
|
12
|
-
return false
|
13
|
-
end
|
7
|
+
User.find_by_id(tag.locals.page.request.session['user_id'])
|
14
8
|
end
|
15
9
|
|
16
10
|
end
|
@@ -5,60 +5,120 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-users-extension}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.1.0.beta"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
11
|
-
s.authors = ["
|
12
|
-
s.date = %q{
|
13
|
-
s.description = %q{
|
14
|
-
s.email =
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dirk Kelly"]
|
12
|
+
s.date = %q{2011-01-18}
|
13
|
+
s.description = %q{Makes Radiant better by adding users!}
|
14
|
+
s.email = ["dk@dirkkelly.com"]
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.md"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"MIT-LICENCE",
|
19
21
|
"README.md",
|
20
22
|
"Rakefile",
|
21
23
|
"VERSION",
|
24
|
+
"app/helpers/admin/users_helper.rb",
|
25
|
+
"app/models/administrator.rb",
|
26
|
+
"app/models/designer.rb",
|
27
|
+
"app/models/user.rb",
|
28
|
+
"app/models/visitor.rb",
|
29
|
+
"app/views/admin/users/_fields.html.haml",
|
30
|
+
"app/views/admin/users/_form.html.haml",
|
31
|
+
"app/views/admin/users/remove.html.haml",
|
32
|
+
"app/views/confirmations/new.html.haml",
|
33
|
+
"app/views/devise_mailer/confirmation_instructions.html.haml",
|
34
|
+
"app/views/devise_mailer/reset_password_instructions.html.haml",
|
35
|
+
"app/views/devise_mailer/unlock_instructions.html.haml",
|
36
|
+
"app/views/mailer/confirmation_instructions.html.haml",
|
37
|
+
"app/views/mailer/reset_password_instructions.html.haml",
|
38
|
+
"app/views/mailer/unlock_instructions.html.haml",
|
39
|
+
"app/views/passwords/edit.html.haml",
|
40
|
+
"app/views/passwords/new.html.haml",
|
41
|
+
"app/views/registrations/edit.html.haml",
|
42
|
+
"app/views/registrations/new.html.haml",
|
43
|
+
"app/views/sessions/new.html.haml",
|
44
|
+
"app/views/shared/_links.html.haml",
|
45
|
+
"app/views/shared/_version.html.haml",
|
46
|
+
"app/views/unlocks/new.html.haml",
|
47
|
+
"config/initializers/devise.rb",
|
48
|
+
"config/initializers/radiant_config.rb",
|
49
|
+
"config/initializers/radiant_devise_encryptor.rb",
|
50
|
+
"config/locales/devise.en.yml",
|
51
|
+
"config/locales/en.yml",
|
22
52
|
"config/routes.rb",
|
23
53
|
"cucumber.yml",
|
24
|
-
"db/migrate/
|
25
|
-
"db/migrate/
|
54
|
+
"db/migrate/20110105024337_change_users_to_devise.rb",
|
55
|
+
"db/migrate/20110105150917_add_class_name_field.rb",
|
56
|
+
"db/migrate/20110107032850_move_permissions_to_class.rb",
|
57
|
+
"db/migrate/20110118103247_change_admin_to_administrator.rb",
|
26
58
|
"features/support/env.rb",
|
27
59
|
"features/support/paths.rb",
|
60
|
+
"lib/login_system.rb",
|
28
61
|
"lib/radiant-users-extension.rb",
|
62
|
+
"lib/radiant-users-extension/version.rb",
|
29
63
|
"lib/tasks/users_extension_tasks.rake",
|
30
|
-
"lib/users/
|
64
|
+
"lib/users/controllers/admin/resource_controller.rb",
|
65
|
+
"lib/users/controllers/admin/welcome_controller.rb",
|
66
|
+
"lib/users/controllers/application_controller.rb",
|
67
|
+
"lib/users/controllers/devise/confirmations_controller.rb",
|
68
|
+
"lib/users/controllers/devise/passwords_controller.rb",
|
69
|
+
"lib/users/controllers/devise/registrations_controller.rb",
|
70
|
+
"lib/users/controllers/devise/sessions_controller.rb",
|
71
|
+
"lib/users/controllers/single_form_body_styles.rb",
|
72
|
+
"lib/users/controllers/site_controller.rb",
|
73
|
+
"lib/users/lib/devise/controllers/internal_helpers.rb",
|
31
74
|
"lib/users/models/user.rb",
|
32
75
|
"lib/users/models/user/scoped.rb",
|
33
76
|
"lib/users/tags/core.rb",
|
77
|
+
"lib/users/tags/helper.rb",
|
34
78
|
"lib/users/tags/helpers.rb",
|
35
79
|
"radiant-users-extension.gemspec",
|
80
|
+
"spec/datasets/devise_users_dataset.rb",
|
36
81
|
"spec/datasets/scoped_users_dataset.rb",
|
37
82
|
"spec/models/user_spec.rb",
|
38
83
|
"spec/models/visitor_spec.rb",
|
39
84
|
"spec/spec.opts",
|
40
85
|
"spec/spec_helper.rb",
|
86
|
+
"spec/tags/core_spec.rb",
|
41
87
|
"users_extension.rb"
|
42
88
|
]
|
43
89
|
s.homepage = %q{http://github.com/dirkkelly/radiant-users-extension}
|
90
|
+
s.post_install_message = %q{
|
91
|
+
Add this to your radiant project with:
|
92
|
+
config.gem 'radiant-users-extension', :version => '2.1.0.beta'
|
93
|
+
}
|
44
94
|
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.
|
46
|
-
s.summary = %q{Users
|
95
|
+
s.rubygems_version = %q{1.4.2}
|
96
|
+
s.summary = %q{Users for Radiant CMS}
|
47
97
|
s.test_files = [
|
98
|
+
"features/support/env.rb",
|
99
|
+
"features/support/paths.rb",
|
100
|
+
"spec/datasets/devise_users_dataset.rb",
|
48
101
|
"spec/datasets/scoped_users_dataset.rb",
|
49
102
|
"spec/models/user_spec.rb",
|
50
103
|
"spec/models/visitor_spec.rb",
|
51
|
-
"spec/
|
104
|
+
"spec/spec.opts",
|
105
|
+
"spec/spec_helper.rb",
|
106
|
+
"spec/tags/core_spec.rb"
|
52
107
|
]
|
53
108
|
|
54
109
|
if s.respond_to? :specification_version then
|
55
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
110
|
s.specification_version = 3
|
57
111
|
|
58
112
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
113
|
+
s.add_runtime_dependency(%q<radiant>, ["~> 0.9"])
|
114
|
+
s.add_runtime_dependency(%q<devise>, ["~> 1.0.9"])
|
59
115
|
else
|
116
|
+
s.add_dependency(%q<radiant>, ["~> 0.9"])
|
117
|
+
s.add_dependency(%q<devise>, ["~> 1.0.9"])
|
60
118
|
end
|
61
119
|
else
|
120
|
+
s.add_dependency(%q<radiant>, ["~> 0.9"])
|
121
|
+
s.add_dependency(%q<devise>, ["~> 1.0.9"])
|
62
122
|
end
|
63
123
|
end
|
64
124
|
|