authentasaurus 0.8.4 → 0.8.6

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.
Files changed (43) hide show
  1. data/CHANGELIST +6 -2
  2. data/TODO +2 -0
  3. data/app/controllers/sessions_controller.rb +1 -1
  4. data/app/models/authentasaurus_emailer.rb +6 -6
  5. data/app/models/{session.rb → authentasaurus_session.rb} +1 -1
  6. data/app/views/authentasaurus_emailer/invitation_mail.html.erb +2 -2
  7. data/app/views/authentasaurus_emailer/recovery_mail.html.erb +2 -2
  8. data/app/views/authentasaurus_emailer/validation_mail.html.erb +2 -2
  9. data/lib/authentasaurus.rb +5 -1
  10. data/lib/authentasaurus/ac/acts_as_overrider.rb +6 -5
  11. data/lib/authentasaurus/ac/controllers/areas_controller.rb +52 -57
  12. data/lib/authentasaurus/ac/controllers/groups_controller.rb +55 -59
  13. data/lib/authentasaurus/ac/controllers/permissions_controller.rb +52 -57
  14. data/lib/authentasaurus/ac/controllers/recoveries_controller.rb +49 -54
  15. data/lib/authentasaurus/ac/controllers/registrations_controller.rb +23 -28
  16. data/lib/authentasaurus/ac/controllers/sessions_controller.rb +39 -40
  17. data/lib/authentasaurus/ac/controllers/user_invitations_controller.rb +29 -34
  18. data/lib/authentasaurus/ac/controllers/users_controller.rb +51 -56
  19. data/lib/authentasaurus/ac/controllers/validations_controller.rb +34 -39
  20. data/lib/authentasaurus/ac/routing.rb +70 -74
  21. data/lib/authentasaurus/ar/acts_as_authenticatable.rb +58 -64
  22. data/lib/authentasaurus/ar/acts_as_authenticatable_validatable.rb +13 -16
  23. data/lib/authentasaurus/ar/acts_as_overrider.rb +1 -3
  24. data/lib/authentasaurus/ar/authenticatable.rb +1 -3
  25. data/lib/authentasaurus/ar/migrations.rb +137 -145
  26. data/lib/authentasaurus/ar/models/recovery.rb +20 -23
  27. data/lib/authentasaurus/ar/models/session.rb +46 -46
  28. data/lib/authentasaurus/ar/models/user_invitation.rb +19 -22
  29. data/lib/authentasaurus/ar/models/validation.rb +12 -15
  30. data/lib/authentasaurus/arel/acts_as_authenticatable.rb +18 -23
  31. data/lib/authentasaurus/arel/authenticatable.rb +5 -9
  32. data/lib/authentasaurus/authorization.rb +11 -8
  33. data/lib/authentasaurus/configuration.rb +30 -0
  34. data/lib/authentasaurus/railtie.rb +3 -6
  35. data/lib/generators/authentasaurus/install/install_generator.rb +1 -2
  36. data/lib/generators/authentasaurus/install/templates/authentasaurus_tasks.rake +2 -2
  37. data/lib/generators/authentasaurus/install/templates/defaults.yml +4 -2
  38. data/lib/generators/authentasaurus/views/templates/authentasaurus_emailer/invitation_mail.html.erb +2 -2
  39. data/lib/generators/authentasaurus/views/templates/authentasaurus_emailer/recovery_mail.html.erb +2 -2
  40. data/lib/generators/authentasaurus/views/templates/authentasaurus_emailer/validation_mail.html.erb +2 -2
  41. data/lib/generators/authentasaurus/views/views_generator.rb +1 -1
  42. metadata +8 -8
  43. data/lib/generators/authentasaurus/install/templates/initializer.rb +0 -3
data/CHANGELIST CHANGED
@@ -1,3 +1,7 @@
1
- =Version 0.4.14 > 0.5.4
1
+ =Version 0.8.4 > 0.8.5
2
2
 
3
- * Improved inheritance of models by adding _model to all models in the libs folder
3
+ * Convert mixins to use ActiveSupport::Concern
4
+ * Improved configuration access
5
+ * Added user_model option to specify the default user model application wide
6
+ * Changed views generator template path to app instead of lib/generators/authentasaurus/views/templates
7
+ * Prefixed session model and routes with authentasaurus to avoid name collisions
data/TODO CHANGED
@@ -1,6 +1,8 @@
1
1
  * Integrate with ActiveModel instead of ActiveRecord
2
2
  * Complete documentation
3
+ * Add HAML support
3
4
  --
5
+ * Convert mixins to use ActiveSupport::Concern [DONE]
4
6
  * Update views to use the new flash convention [DONE]
5
7
  * flash[:notice] for information messages [DONE]
6
8
  * flash[:alert] for error messages [DONE]
@@ -1,3 +1,3 @@
1
1
  class SessionsController < ApplicationController
2
2
  acts_as_sessions
3
- end
3
+ end
@@ -1,8 +1,8 @@
1
1
  class AuthentasaurusEmailer < ActionMailer::Base
2
2
  def validation_mail(name, email, validation_code, sent_at = Time.now)
3
- subject Rails.application.config.authentasaurus[:modules][:validatable][:mail_subject]
3
+ subject Authentasaurus::Configuration.instance.configuration[:modules][:validatable][:mail_subject]
4
4
  recipients email
5
- from Rails.application.config.authentasaurus[:modules][:validatable][:mail_from]
5
+ from Authentasaurus::Configuration.instance.configuration[:modules][:validatable][:mail_from]
6
6
  sent_on sent_at
7
7
 
8
8
  body :name => name, :vcode => validation_code
@@ -10,9 +10,9 @@ class AuthentasaurusEmailer < ActionMailer::Base
10
10
  end
11
11
 
12
12
  def recovery_mail(user, token, sent_at = Time.now)
13
- subject Rails.application.config.authentasaurus[:modules][:recoverable][:mail_subject]
13
+ subject Authentasaurus::Configuration.instance.configuration[:modules][:recoverable][:mail_subject]
14
14
  recipients user.email
15
- from Rails.application.config.authentasaurus[:modules][:recoverable][:mail_from] # dont forget to change me
15
+ from Authentasaurus::Configuration.instance.configuration[:modules][:recoverable][:mail_from] # dont forget to change me
16
16
  sent_on sent_at
17
17
 
18
18
  body :name => user.name, :token => token
@@ -20,9 +20,9 @@ class AuthentasaurusEmailer < ActionMailer::Base
20
20
  end
21
21
 
22
22
  def invitation_mail(email, token, sent_at = Time.now)
23
- subject Rails.application.config.authentasaurus[:modules][:invitable][:mail_subject]
23
+ subject Authentasaurus::Configuration.instance.configuration[:modules][:invitable][:mail_subject]
24
24
  recipients email
25
- from Rails.application.config.authentasaurus[:modules][:invitable][:mail_from]
25
+ from Authentasaurus::Configuration.instance.configuration[:modules][:invitable][:mail_from]
26
26
  sent_on sent_at
27
27
 
28
28
  body :token => token
@@ -1,3 +1,3 @@
1
- class Session
1
+ class AuthentasaurusSession
2
2
  include Authentasaurus::Ar::Models::Session
3
3
  end
@@ -1,4 +1,4 @@
1
- <p>You've been invited to create an account at <%= Rails.application.config.authentasaurus[:mail][:host] %> follow this <%= link_to "link", new_registrations_url(:host => Rails.application.config.authentasaurus[:mail][:host], :token => @token) %> to respond to the invitation.</p>
1
+ <p>You've been invited to create an account at <%= Authentasaurus::Configuration.instance.configuration[:mail][:host] %> follow this <%= link_to "link", new_registrations_url(:host => Authentasaurus::Configuration.instance.configuration[:mail][:host], :token => @token) %> to respond to the invitation.</p>
2
2
 
3
3
  <p>Best Regards,</p>
4
- <p><%= Rails.application.config.authentasaurus[:mail][:host] %> Team</p>
4
+ <p><%= Authentasaurus::Configuration.instance.configuration[:mail][:host] %> Team</p>
@@ -1,7 +1,7 @@
1
1
  <p>Dear <%= @name %>,</p>
2
2
 
3
3
  <p>A request has been made to recover your account's password.</p>
4
- <p>Please visit this <%= link_to "link", recover_password_url(:host => Rails.application.config.authentasaurus[:mail][:host], :token => @token) %> and follow the instructions.</p>
4
+ <p>Please visit this <%= link_to "link", recover_password_url(:host => Authentasaurus::Configuration.instance.configuration[:mail][:host], :token => @token) %> and follow the instructions.</p>
5
5
 
6
6
  <p>Best Regards,</p>
7
- <p><%= Rails.application.config.authentasaurus[:mail][:host] %> Team</p>
7
+ <p><%= Authentasaurus::Configuration.instance.configuration[:mail][:host] %> Team</p>
@@ -1,6 +1,6 @@
1
1
  <p>Dear <%= @name %>,</p>
2
2
 
3
- <p>Please validate your account at <%= Rails.application.config.authentasaurus[:mail][:host] %> by visiting this <%= link_to "link", activate_url(:host => Rails.application.config.authentasaurus[:mail][:host] , :code => @vcode) %>.</p>
3
+ <p>Please validate your account at <%= Authentasaurus::Configuration.instance.configuration[:mail][:host] %> by visiting this <%= link_to "link", activate_url(:host => Authentasaurus::Configuration.instance.configuration[:mail][:host] , :code => @vcode) %>.</p>
4
4
 
5
5
  <p>Best Regards,</p>
6
- <p><%= Rails.application.config.authentasaurus[:mail][:host] %> Team</p>
6
+ <p><%= Authentasaurus::Configuration.instance.configuration[:mail][:host] %> Team</p>
@@ -1,5 +1,6 @@
1
1
  module Authentasaurus
2
- require 'authentasaurus/railtie' if defined?(Rails) # NEVER EVER REMOVE THIS LINE !!!
2
+ require 'authentasaurus/configuration'
3
+ require 'authentasaurus/railtie' #if defined?(Rails) # NEVER EVER REMOVE THIS LINE !!!
3
4
  # Authorization Helpers
4
5
  require 'authentasaurus/authorization'
5
6
  # Controllers, Views and Routes helpers
@@ -9,6 +10,9 @@ module Authentasaurus
9
10
  require 'authentasaurus/ar/acts_as_overrider'
10
11
  require 'authentasaurus/ar/authenticatable'
11
12
  require 'authentasaurus/ar/migrations'
13
+ require 'authentasaurus/ar/acts_as_authenticatable'
14
+ require 'authentasaurus/ar/acts_as_authenticatable_validatable'
15
+ require 'authentasaurus/arel/acts_as_authenticatable'
12
16
  # ActiveResource Helpers
13
17
  require 'authentasaurus/arel/authenticatable'
14
18
 
@@ -1,10 +1,8 @@
1
- module Authentasaurus::Ac
1
+ module Authentasaurus::Ac
2
2
  Dir[File.dirname(__FILE__) + '/controllers/*.rb'].each {|file| require file }
3
3
 
4
4
  module ActsAsOverrider
5
- def self.included(base)
6
- base.send :extend, ClassMethods
7
- end
5
+ extend ActiveSupport::Concern
8
6
 
9
7
  module ClassMethods
10
8
  def acts_as_areas
@@ -27,7 +25,10 @@ module Authentasaurus::Ac
27
25
  include Authentasaurus::Ac::Controllers::RegistrationsController
28
26
  end
29
27
 
30
- def acts_as_sessions
28
+ def acts_as_sessions(user_model = nil)
29
+ cattr_accessor :user_model
30
+ self.user_model = user_model || Authentasaurus::Configuration.instance.user_model.to_sym
31
+
31
32
  include Authentasaurus::Ac::Controllers::SessionsController
32
33
  end
33
34
 
@@ -1,80 +1,75 @@
1
1
  module Authentasaurus::Ac::Controllers
2
2
  module AreasController
3
- def self.included(base) # :nodoc:
4
- base.send :extend, ClassMethods
5
- base.send :include, InstanceMethods
6
- end
3
+ extend ActiveSupport::Concern
7
4
 
8
5
  module ClassMethods
9
6
  end
10
-
11
- module InstanceMethods
12
- def index
13
- @areas= Area.find :all
14
7
 
15
- respond_to do |format|
16
- format.html
17
- end
8
+ def index
9
+ @areas= Area.find :all
10
+
11
+ respond_to do |format|
12
+ format.html
18
13
  end
14
+ end
15
+
16
+ def show
17
+ @area = Area.find params[:id]
19
18
 
20
- def show
21
- @area = Area.find params[:id]
22
-
23
- respond_to do |format|
24
- format.html
25
- end
19
+ respond_to do |format|
20
+ format.html
26
21
  end
22
+ end
23
+
24
+ def new
25
+ @area = Area.new
27
26
 
28
- def new
29
- @area = Area.new
30
-
31
- respond_to do |format|
32
- format.html
33
- end
27
+ respond_to do |format|
28
+ format.html
34
29
  end
30
+ end
31
+
32
+ def create
33
+ @area = Area.new params[:area]
35
34
 
36
- def create
37
- @area = Area.new params[:area]
38
-
39
- respond_to do |format|
40
- if @area.save
41
- format.html { redirect_to :action=>:index, :notice => "Area Created" }
42
- else
43
- flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :areas])
44
- format.html { render :new }
45
- end
35
+ respond_to do |format|
36
+ if @area.save
37
+ format.html { redirect_to :action=>:index, :notice => "Area Created" }
38
+ else
39
+ flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :areas])
40
+ format.html { render :new }
46
41
  end
47
42
  end
43
+ end
44
+
45
+ def edit
46
+ @area = Area.find params[:id]
48
47
 
49
- def edit
50
- @area = Area.find params[:id]
51
-
52
- respond_to do |format|
53
- format.html
54
- end
48
+ respond_to do |format|
49
+ format.html
55
50
  end
51
+ end
52
+
53
+ def update
54
+ @area = Area.find params[:id]
56
55
 
57
- def update
58
- @area = Area.find params[:id]
59
-
60
- respond_to do |format|
61
- if @area.update_attributes(params[:area])
62
- format.html { redirect_to :action => :index, :notice => "Area updated" }
63
- else
64
- flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :areas])
65
- format.html { render :edit }
66
- end
56
+ respond_to do |format|
57
+ if @area.update_attributes(params[:area])
58
+ format.html { redirect_to :action => :index, :notice => "Area updated" }
59
+ else
60
+ flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :areas])
61
+ format.html { render :edit }
67
62
  end
68
63
  end
64
+ end
65
+
66
+ def destroy
67
+ @area = Area.find params[:id]
68
+ @area.destroy
69
69
 
70
- def destroy
71
- @area = Area.find params[:id]
72
- @area.destroy
73
-
74
- respond_to do |format|
75
- format.html { redirect_to :action=>:index }
76
- end
70
+ respond_to do |format|
71
+ format.html { redirect_to :action=>:index }
77
72
  end
78
73
  end
79
- end
74
+ end
80
75
  end
@@ -1,81 +1,77 @@
1
1
  module Authentasaurus::Ac::Controllers
2
2
  module GroupsController
3
- def self.included(base) # :nodoc:
4
- base.send :extend, ClassMethods
5
- base.send :include, InstanceMethods
6
- end
3
+ extend ActiveSupport::Concern
7
4
 
8
5
  module ClassMethods
9
6
  end
10
7
 
11
- module InstanceMethods
12
- def index
13
- @groups = Group.find :all
14
-
15
- respond_to do |format|
16
- format.html
17
- end
8
+
9
+ def index
10
+ @groups = Group.find :all
11
+
12
+ respond_to do |format|
13
+ format.html
18
14
  end
15
+ end
16
+
17
+ def show
18
+ @group = Group.find params[:id]
19
19
 
20
- def show
21
- @group = Group.find params[:id]
22
-
23
- respond_to do |format|
24
- format.html
25
- end
20
+ respond_to do |format|
21
+ format.html
26
22
  end
23
+ end
24
+
25
+ def new
26
+ @group = Group.new
27
27
 
28
- def new
29
- @group = Group.new
30
-
31
- respond_to do |format|
32
- format.html
33
- end
28
+ respond_to do |format|
29
+ format.html
34
30
  end
31
+ end
32
+
33
+ def create
34
+ @group = Group.new params[:group]
35
35
 
36
- def create
37
- @group = Group.new params[:group]
38
-
39
- respond_to do |format|
40
- if @group.save
41
- format.html { redirect_to :action=>:index, :notice => "Group created" }
42
- else
43
- flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :groups])
44
- format.html { render :new }
45
- end
36
+ respond_to do |format|
37
+ if @group.save
38
+ format.html { redirect_to :action=>:index, :notice => "Group created" }
39
+ else
40
+ flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :groups])
41
+ format.html { render :new }
46
42
  end
47
43
  end
44
+ end
45
+
46
+ def edit
47
+ @group = Group.find params[:id]
48
48
 
49
- def edit
50
- @group = Group.find params[:id]
51
-
52
- respond_to do |format|
53
- format.html
54
- end
49
+ respond_to do |format|
50
+ format.html
55
51
  end
52
+ end
53
+
54
+ def update
55
+ @group = Group.find params[:id]
56
56
 
57
- def update
58
- @group = Group.find params[:id]
59
-
60
- respond_to do |format|
61
- if @group.update_attributes(params[:group])
62
- format.html { redirect_to :action => :index, :notice => "Group updated" }
63
- else
64
- flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :groups])
65
- format.html { render :edit }
66
- end
57
+ respond_to do |format|
58
+ if @group.update_attributes(params[:group])
59
+ format.html { redirect_to :action => :index, :notice => "Group updated" }
60
+ else
61
+ flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :groups])
62
+ format.html { render :edit }
67
63
  end
68
-
69
64
  end
70
65
 
71
- def destroy
72
- @group = Group.find params[:id]
73
- @group.destroy
74
-
75
- respond_to do |format|
76
- format.html { redirect_to :action=>:index }
77
- end
78
- end
79
66
  end
80
- end
67
+
68
+ def destroy
69
+ @group = Group.find params[:id]
70
+ @group.destroy
71
+
72
+ respond_to do |format|
73
+ format.html { redirect_to :action=>:index }
74
+ end
75
+ end
76
+ end
81
77
  end
@@ -1,80 +1,75 @@
1
1
  module Authentasaurus::Ac::Controllers
2
2
  module PermissionsController
3
- def self.included(base) # :nodoc:
4
- base.send :extend, ClassMethods
5
- base.send :include, InstanceMethods
6
- end
3
+ extend ActiveSupport::Concern
7
4
 
8
5
  module ClassMethods
9
6
  end
10
-
11
- module InstanceMethods
12
- def index
13
- @permissions = Permission.find :all
14
7
 
15
- respond_to do |format|
16
- format.html
17
- end
8
+ def index
9
+ @permissions = Permission.find :all
10
+
11
+ respond_to do |format|
12
+ format.html
18
13
  end
14
+ end
15
+
16
+ def show
17
+ @permission = Permission.find params[:id]
19
18
 
20
- def show
21
- @permission = Permission.find params[:id]
22
-
23
- respond_to do |format|
24
- format.html
25
- end
19
+ respond_to do |format|
20
+ format.html
26
21
  end
22
+ end
23
+
24
+ def new
25
+ @permission = Permission.new
27
26
 
28
- def new
29
- @permission = Permission.new
30
-
31
- respond_to do |format|
32
- format.html
33
- end
27
+ respond_to do |format|
28
+ format.html
34
29
  end
30
+ end
31
+
32
+ def create
33
+ @permission = Permission.new params[:permission]
35
34
 
36
- def create
37
- @permission = Permission.new params[:permission]
38
-
39
- respond_to do |format|
40
- if @permission.save
41
- format.html { redirect_to :action=>:index, :notice => "Permission created" }
42
- else
43
- flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :permissions])
44
- format.html { render :new }
45
- end
35
+ respond_to do |format|
36
+ if @permission.save
37
+ format.html { redirect_to :action=>:index, :notice => "Permission created" }
38
+ else
39
+ flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :permissions])
40
+ format.html { render :new }
46
41
  end
47
42
  end
43
+ end
44
+
45
+ def edit
46
+ @permission = Permission.find params[:id]
48
47
 
49
- def edit
50
- @permission = Permission.find params[:id]
51
-
52
- respond_to do |format|
53
- format.html
54
- end
48
+ respond_to do |format|
49
+ format.html
55
50
  end
51
+ end
52
+
53
+ def update
54
+ @permission = Permission.find params[:id]
56
55
 
57
- def update
58
- @permission = Permission.find params[:id]
59
-
60
- respond_to do |format|
61
- if @permission.update_attributes(params[:permission])
62
- flash.now[:notice] = "Permission updated"
63
- format.html { redirect_to :action => :index }
64
- else
65
- flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :permissions])
66
- format.html { render :edit }
67
- end
56
+ respond_to do |format|
57
+ if @permission.update_attributes(params[:permission])
58
+ flash.now[:notice] = "Permission updated"
59
+ format.html { redirect_to :action => :index }
60
+ else
61
+ flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :permissions])
62
+ format.html { render :edit }
68
63
  end
69
64
  end
65
+ end
66
+
67
+ def destroy
68
+ @permission = Permission.find params[:id]
69
+ @permission.destroy
70
70
 
71
- def destroy
72
- @permission = Permission.find params[:id]
73
- @permission.destroy
74
-
75
- respond_to do |format|
76
- format.html { redirect_to :action=>:index }
77
- end
71
+ respond_to do |format|
72
+ format.html { redirect_to :action=>:index }
78
73
  end
79
74
  end
80
75
  end