authentasaurus 0.7.3 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/TODO +3 -0
  2. data/app/controllers/areas_controller.rb +1 -1
  3. data/app/controllers/groups_controller.rb +1 -1
  4. data/app/controllers/permissions_controller.rb +1 -1
  5. data/app/controllers/recoveries_controller.rb +1 -1
  6. data/app/controllers/registrations_controller.rb +1 -1
  7. data/app/controllers/sessions_controller.rb +1 -1
  8. data/app/controllers/user_invitations_controller.rb +1 -1
  9. data/app/controllers/users_controller.rb +1 -1
  10. data/app/controllers/validations_controller.rb +1 -1
  11. data/app/models/area.rb +1 -1
  12. data/app/models/group.rb +1 -1
  13. data/app/models/permission.rb +1 -1
  14. data/app/models/recovery.rb +1 -1
  15. data/app/models/session.rb +1 -1
  16. data/app/models/user_invitation.rb +1 -1
  17. data/app/models/validation.rb +1 -1
  18. data/lib/authentasaurus.rb +22 -36
  19. data/lib/authentasaurus/ac/acts_as_overrider.rb +47 -0
  20. data/lib/authentasaurus/ac/controllers/areas_controller.rb +80 -0
  21. data/lib/authentasaurus/ac/controllers/groups_controller.rb +81 -0
  22. data/lib/authentasaurus/ac/controllers/permissions_controller.rb +81 -0
  23. data/lib/authentasaurus/ac/controllers/recoveries_controller.rb +72 -0
  24. data/lib/authentasaurus/ac/controllers/registrations_controller.rb +45 -0
  25. data/lib/authentasaurus/ac/controllers/sessions_controller.rb +58 -0
  26. data/lib/authentasaurus/ac/controllers/user_invitations_controller.rb +50 -0
  27. data/lib/authentasaurus/ac/controllers/users_controller.rb +80 -0
  28. data/lib/authentasaurus/ac/controllers/validations_controller.rb +53 -0
  29. data/lib/authentasaurus/ac/routing.rb +90 -0
  30. data/lib/authentasaurus/ar/acts_as_authenticatable.rb +113 -0
  31. data/lib/authentasaurus/ar/acts_as_authenticatable_validatable.rb +38 -0
  32. data/lib/authentasaurus/ar/acts_as_overrider.rb +51 -0
  33. data/lib/authentasaurus/ar/authenticatable.rb +66 -0
  34. data/lib/authentasaurus/ar/migrations.rb +173 -0
  35. data/lib/authentasaurus/{models → ar/models}/recovery.rb +3 -3
  36. data/lib/authentasaurus/{models → ar/models}/session.rb +1 -1
  37. data/lib/authentasaurus/{models → ar/models}/user_invitation.rb +1 -1
  38. data/lib/authentasaurus/{models → ar/models}/validation.rb +1 -1
  39. data/lib/authentasaurus/arel/acts_as_authenticatable.rb +72 -0
  40. data/lib/authentasaurus/arel/authenticatable.rb +25 -0
  41. data/lib/authentasaurus/authorization.rb +341 -0
  42. data/lib/authentasaurus/railtie.rb +4 -4
  43. data/lib/generators/authentasaurus/install/templates/initializer.rb +1 -1
  44. data/rdoc/apple-touch-icon.png +0 -0
  45. data/rdoc/classes/Authentasaurus.html +65 -0
  46. data/rdoc/classes/Authentasaurus/Ac.html +72 -0
  47. data/rdoc/classes/Authentasaurus/Ac/ActsAsOverrider.html +104 -0
  48. data/rdoc/classes/Authentasaurus/Ac/ActsAsOverrider/ClassMethods.html +397 -0
  49. data/rdoc/classes/Authentasaurus/Ac/Routing.html +61 -0
  50. data/rdoc/classes/Authentasaurus/Ac/Routing/InstanceMethods.html +390 -0
  51. data/rdoc/classes/Authentasaurus/Ar.html +77 -0
  52. data/rdoc/classes/Authentasaurus/Ar/ActsAsAuthenticatable.html +107 -0
  53. data/rdoc/classes/Authentasaurus/Ar/ActsAsAuthenticatable/ClassMethods.html +168 -0
  54. data/rdoc/classes/Authentasaurus/Ar/ActsAsAuthenticatable/InstanceMethods.html +357 -0
  55. data/rdoc/classes/Authentasaurus/Ar/ActsAsAuthenticatableValidatable.html +109 -0
  56. data/rdoc/classes/Authentasaurus/Ar/ActsAsAuthenticatableValidatable/ClassMethods.html +113 -0
  57. data/rdoc/classes/Authentasaurus/Ar/ActsAsAuthenticatableValidatable/InstanceMethods.html +54 -0
  58. data/rdoc/classes/Authentasaurus/Ar/ActsAsOverrider.html +104 -0
  59. data/rdoc/classes/Authentasaurus/Ar/ActsAsOverrider/ClassMethods.html +320 -0
  60. data/rdoc/classes/Authentasaurus/Ar/Authenticatable.html +104 -0
  61. data/rdoc/classes/Authentasaurus/Ar/Authenticatable/ClassMethods.html +182 -0
  62. data/rdoc/classes/Authentasaurus/Ar/Migrations.html +63 -0
  63. data/rdoc/classes/Authentasaurus/Ar/Migrations/Columns.html +68 -0
  64. data/rdoc/classes/Authentasaurus/Ar/Migrations/Columns/InstanceMethods.html +106 -0
  65. data/rdoc/classes/Authentasaurus/Ar/Migrations/Tables.html +68 -0
  66. data/rdoc/classes/Authentasaurus/Ar/Migrations/Tables/InstanceMethods.html +703 -0
  67. data/rdoc/classes/Authentasaurus/Arel.html +65 -0
  68. data/rdoc/classes/Authentasaurus/Arel/ActsAsAuthenticatable.html +107 -0
  69. data/rdoc/classes/Authentasaurus/Arel/ActsAsAuthenticatable/ClassMethods.html +139 -0
  70. data/rdoc/classes/Authentasaurus/Arel/ActsAsAuthenticatable/InstanceMethods.html +113 -0
  71. data/rdoc/classes/Authentasaurus/Arel/Authenticatable.html +105 -0
  72. data/rdoc/classes/Authentasaurus/Arel/Authenticatable/ClassMethods.html +119 -0
  73. data/rdoc/classes/Authentasaurus/Authorization.html +230 -0
  74. data/rdoc/classes/Authentasaurus/Authorization/ActionController.html +63 -0
  75. data/rdoc/classes/Authentasaurus/Authorization/ActionController/ClassMethods.html +263 -0
  76. data/rdoc/classes/Authentasaurus/Authorization/ActionController/InstanceMethods.html +54 -0
  77. data/rdoc/classes/Authentasaurus/Authorization/ActionView.html +54 -0
  78. data/rdoc/classes/Authentasaurus/Authorization/CommonInstanceMethods.html +240 -0
  79. data/rdoc/created.rid +1 -0
  80. data/rdoc/css/main.css +278 -0
  81. data/rdoc/css/panel.css +383 -0
  82. data/rdoc/css/reset.css +53 -0
  83. data/rdoc/favicon.ico +0 -0
  84. data/rdoc/files/README_rdoc.html +366 -0
  85. data/rdoc/files/TODO.html +64 -0
  86. data/rdoc/files/lib/authentasaurus/ac/acts_as_overrider_rb.html +52 -0
  87. data/rdoc/files/lib/authentasaurus/ac/routing_rb.html +60 -0
  88. data/rdoc/files/lib/authentasaurus/ar/acts_as_authenticatable_rb.html +52 -0
  89. data/rdoc/files/lib/authentasaurus/ar/acts_as_authenticatable_validatable_rb.html +52 -0
  90. data/rdoc/files/lib/authentasaurus/ar/acts_as_overrider_rb.html +52 -0
  91. data/rdoc/files/lib/authentasaurus/ar/authenticatable_rb.html +52 -0
  92. data/rdoc/files/lib/authentasaurus/ar/migrations_rb.html +52 -0
  93. data/rdoc/files/lib/authentasaurus/arel/acts_as_authenticatable_rb.html +52 -0
  94. data/rdoc/files/lib/authentasaurus/arel/authenticatable_rb.html +72 -0
  95. data/rdoc/files/lib/authentasaurus/authorization_rb.html +208 -0
  96. data/rdoc/i/arrows.png +0 -0
  97. data/rdoc/i/results_bg.png +0 -0
  98. data/rdoc/i/tree_bg.png +0 -0
  99. data/rdoc/index.html +15 -0
  100. data/rdoc/js/jquery-1.3.2.min.js +19 -0
  101. data/rdoc/js/jquery-effect.js +593 -0
  102. data/rdoc/js/main.js +22 -0
  103. data/rdoc/js/searchdoc.js +628 -0
  104. data/rdoc/panel/index.html +71 -0
  105. data/rdoc/panel/search_index.js +1 -0
  106. data/rdoc/panel/tree.js +1 -0
  107. metadata +92 -44
  108. data/lib/action_controller/authorization.rb +0 -215
  109. data/lib/action_view/authorization.rb +0 -52
  110. data/lib/active_record/acts_as_authenticatable.rb +0 -111
  111. data/lib/active_record/acts_as_authenticatable_validatable.rb +0 -36
  112. data/lib/active_record/authenticatable.rb +0 -64
  113. data/lib/active_resource/acts_as_authenticatable.rb +0 -70
  114. data/lib/active_resource/authenticatable.rb +0 -24
  115. data/lib/authentasaurus/areas_controller.rb +0 -78
  116. data/lib/authentasaurus/groups_controller.rb +0 -79
  117. data/lib/authentasaurus/models/area.rb +0 -21
  118. data/lib/authentasaurus/models/group.rb +0 -19
  119. data/lib/authentasaurus/models/permission.rb +0 -24
  120. data/lib/authentasaurus/permissions_controller.rb +0 -79
  121. data/lib/authentasaurus/recoveries_controller.rb +0 -70
  122. data/lib/authentasaurus/registrations_controller.rb +0 -43
  123. data/lib/authentasaurus/sessions_controller.rb +0 -56
  124. data/lib/authentasaurus/user_invitations_controller.rb +0 -48
  125. data/lib/authentasaurus/users_controller.rb +0 -78
  126. data/lib/authentasaurus/validations_controller.rb +0 -51
  127. data/lib/helpers/migrations.rb +0 -171
  128. data/lib/helpers/routing.rb +0 -87
@@ -1,21 +0,0 @@
1
- module Authentasaurus::Models
2
- module Area
3
- def self.included(base) # :nodoc:
4
- base.send :extend, ClassMethods
5
- base.send :include, InstanceMethods
6
-
7
- base.send :unloadable
8
-
9
- base.send :has_many, :permissions, :dependent => :destroy
10
- base.send :has_many, :groups, :through => :permissions
11
-
12
- base.send :validates_presence_of, :name
13
- end
14
-
15
- module ClassMethods
16
- end
17
-
18
- module InstanceMethods
19
- end
20
- end
21
- end
@@ -1,19 +0,0 @@
1
- module Authentasaurus::Models
2
- module Group
3
- def self.included(base) # :nodoc:
4
- base.send :extend, ClassMethods
5
- base.send :include, InstanceMethods
6
-
7
- base.send :has_many, :permissions, :dependent => :destroy
8
- base.send :has_many, :areas, :through => :permissions
9
-
10
- base.send :validates_presence_of, :name
11
- end
12
-
13
- module ClassMethods
14
- end
15
-
16
- module InstanceMethods
17
- end
18
- end
19
- end
@@ -1,24 +0,0 @@
1
- module Authentasaurus::Models
2
- module Permission
3
- def self.included(base) # :nodoc:
4
- base.send :extend, ClassMethods
5
- base.send :include, InstanceMethods
6
-
7
- base.send :unloadable
8
-
9
- base.send :belongs_to, :group
10
- base.send :belongs_to, :area
11
-
12
- # Check that everything is there
13
- base.send :validates_presence_of, :group_id, :area_id
14
- # Check foreign keys
15
- base.send :validates_associated, :group, :area
16
- end
17
-
18
- module ClassMethods
19
- end
20
-
21
- module InstanceMethods
22
- end
23
- end
24
- end
@@ -1,79 +0,0 @@
1
- module Authentasaurus::PermissionsController
2
- def self.included(base) # :nodoc:
3
- base.send :extend, ClassMethods
4
- base.send :include, InstanceMethods
5
- end
6
-
7
- module ClassMethods
8
- end
9
-
10
- module InstanceMethods
11
- def index
12
- @permissions = Permission.find :all
13
-
14
- respond_to do |format|
15
- format.html
16
- end
17
- end
18
-
19
- def show
20
- @permission = Permission.find params[:id]
21
-
22
- respond_to do |format|
23
- format.html
24
- end
25
- end
26
-
27
- def new
28
- @permission = Permission.new
29
-
30
- respond_to do |format|
31
- format.html
32
- end
33
- end
34
-
35
- def create
36
- @permission = Permission.new params[:permission]
37
-
38
- respond_to do |format|
39
- if @permission.save
40
- format.html { redirect_to :action=>:index, :notice => "Permission created" }
41
- else
42
- flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :permissions])
43
- format.html { render :new }
44
- end
45
- end
46
- end
47
-
48
- def edit
49
- @permission = Permission.find params[:id]
50
-
51
- respond_to do |format|
52
- format.html
53
- end
54
- end
55
-
56
- def update
57
- @permission = Permission.find params[:id]
58
-
59
- respond_to do |format|
60
- if @permission.update_attributes(params[:permission])
61
- flash.now[:notice] = "Permission updated"
62
- format.html { redirect_to :action => :index }
63
- else
64
- flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :permissions])
65
- format.html { render :edit }
66
- end
67
- end
68
- end
69
-
70
- def destroy
71
- @permission = Permission.find params[:id]
72
- @permission.destroy
73
-
74
- respond_to do |format|
75
- format.html { redirect_to :action=>:index }
76
- end
77
- end
78
- end
79
- end
@@ -1,70 +0,0 @@
1
- module Authentasaurus::RecoveriesController
2
- def self.included(base) # :nodoc:
3
- base.send :extend, ClassMethods
4
- base.send :include, InstanceMethods
5
- end
6
-
7
- module ClassMethods
8
- end
9
-
10
- module InstanceMethods
11
- def new
12
- @recovery = Recovery.new
13
-
14
- respond_to do |format|
15
- format.html
16
- end
17
- end
18
-
19
- def create
20
- @recovery = Recovery.find_or_initialize_by_email :email => params[:email]
21
-
22
- if @recovery.new_record?
23
- @recovery.user = User.find_by_email @recovery.email
24
- end
25
-
26
- respond_to do |format|
27
- if @recovery.save
28
- @recovery.touch
29
- format.html { redirect_to new_session_path, :notice => t(:recovery_email_sent, :scope => [:authentasaurus, :messages, :recoveries], :email => @recovery.email) }
30
- else
31
- format.html {render :new}
32
- end
33
- end
34
- end
35
-
36
- def edit
37
- @recovery = Recovery.valid.find_by_token(params[:token])
38
-
39
- respond_to do |format|
40
- unless @recovery.nil?
41
- @user = @recovery.user
42
- format.html
43
- else
44
- format.html { redirect_to new_session_path, :alert => t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
45
- end
46
- end
47
- end
48
-
49
- def destroy
50
- @recovery = Recovery.find_by_token params[:token]
51
- @user = @recovery.user
52
-
53
- respond_to do |format|
54
- empty_fields = params[:user].select { |key, value| value.blank? }
55
- if !empty_fields.empty?
56
- empty_fields.each do |f|
57
- @user.errors.add_to_base t(:recovery_field_blank, :scope => [:authentasaurus, :messages, :recoveries], :field => f.first.humanize)
58
- end
59
- format.html { render :edit }
60
- elsif @user.update_attributes params[:user]
61
- @recovery.destroy
62
- format.html { redirect_to new_session_path, :notice => t(:recovery_successful, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
63
- else
64
- flash.now[:alert] = t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email])
65
- format.html { render :edit }
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,43 +0,0 @@
1
- module Authentasaurus::RegistrationsController
2
- def self.included(base) # :nodoc:
3
- base.send :extend, ClassMethods
4
- base.send :include, InstanceMethods
5
- end
6
-
7
- module ClassMethods
8
- end
9
-
10
- module InstanceMethods
11
- def new
12
- @user = User.new
13
- @user_invitation = UserInvitation.find_by_token params[:token]
14
-
15
- respond_to do |format|
16
- if @user_invitation.nil?
17
- format.html {redirect_to new_session_path, :alert => t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])}
18
- else
19
- @user.email = @user_invitation.email
20
- format.html
21
- end
22
- end
23
- end
24
-
25
- def create
26
- @user = User.new params[:user]
27
- user_invitation = UserInvitation.find_by_token params[:token]
28
-
29
- respond_to do |format|
30
- unless user_invitation.nil?
31
- if @user.save
32
- format.html {redirect_to new_session_path}
33
- else
34
- format.html {render :new}
35
- end
36
- else
37
- flash.now[:alert] = t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])
38
- format.html {render :new}
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,56 +0,0 @@
1
- module Authentasaurus::SessionsController
2
- def self.included(base) # :nodoc:
3
- base.send :extend, ClassMethods
4
- base.send :include, InstanceMethods
5
-
6
- base.send :before_filter, :check_is_logged_in, :except => [:destroy, :no_access]
7
- end
8
-
9
- module ClassMethods
10
- end
11
-
12
- module InstanceMethods
13
- def new
14
- @session = Session.new
15
-
16
- respond_to do |format|
17
- format.html
18
- end
19
- end
20
-
21
- def create
22
- @session = Session.new params[:session]
23
-
24
- respond_to do |format|
25
- if @session.save
26
- if @session.remember == "1"
27
- cookies.signed.permanent[:remember_me_token] = @session.user.remember_me_token
28
- end
29
- session[:user_id] = @session.user.id
30
- session[:user_permissions] = {:read => @session.user.permissions.collect{|per| per.area.name if per.read}, :write => @session.user.permissions.collect{|per| per.area.name if per.write}}
31
- format.html { redirect_to session[:original_url] || (defined?(signin_redirect_path).nil? ? root_path : signin_redirect_path) }
32
- else
33
- format.html { render :action => :new }
34
- end
35
- end
36
-
37
- end
38
-
39
- def destroy
40
- session[:user_id] = nil
41
- session[:user_permissions] = nil
42
- cookies.delete :remember_me_token
43
-
44
- respond_to do |format|
45
- format.html { redirect_to :action => :new }
46
- end
47
- end
48
-
49
- private
50
- def check_is_logged_in
51
- if is_logged_in?
52
- redirect_to defined?(signin_redirect_path).nil? ? root_path : signin_redirect_path
53
- end
54
- end
55
- end
56
- end
@@ -1,48 +0,0 @@
1
- module Authentasaurus::UserInvitationsController
2
- def self.included(base) # :nodoc:
3
- base.send :extend, ClassMethods
4
- base.send :include, InstanceMethods
5
- end
6
-
7
- module ClassMethods
8
- end
9
-
10
- module InstanceMethods
11
- def index
12
- @invitations = UserInvitation.find :all
13
-
14
- respond_to do |format|
15
- format.html
16
- end
17
- end
18
-
19
- def new
20
- @invitation = UserInvitation.new
21
-
22
- respond_to do |format|
23
- format.html
24
- end
25
- end
26
-
27
- def create
28
- @invitation = UserInvitation.new params[:user_invitation]
29
-
30
- respond_to do |format|
31
- if @invitation.save
32
- format.html { redirect_to :action => :index }
33
- else
34
- format.html {render :new}
35
- end
36
- end
37
- end
38
-
39
- def destroy
40
- invitation = UserInvitation.find params[:id]
41
- invitation.destroy
42
-
43
- respond_to do |format|
44
- format.html { redirect_to :action => :index }
45
- end
46
- end
47
- end
48
- end
@@ -1,78 +0,0 @@
1
- module Authentasaurus::UsersController
2
- def self.included(base) # :nodoc:
3
- base.send :extend, ClassMethods
4
- base.send :include, InstanceMethods
5
- end
6
-
7
- module ClassMethods
8
- end
9
-
10
- module InstanceMethods
11
- def index
12
- @users = User.all
13
-
14
- respond_to do |format|
15
- format.html
16
- end
17
- end
18
-
19
- def show
20
- @user = User.find(params[:id])
21
-
22
- respond_to do |format|
23
- format.html
24
- end
25
- end
26
-
27
- def new
28
- @user = User.new
29
-
30
- respond_to do |format|
31
- format.html
32
- end
33
- end
34
-
35
- def create
36
- @user = User.new params[:user]
37
-
38
- respond_to do |format|
39
- if @user.save
40
- format.html { redirect_to :action=>:index, :notice => "User saved successfully" }
41
- else
42
- flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :users])
43
- format.html { render :new }
44
- end
45
- end
46
- end
47
-
48
- def edit
49
- @user = User.find params[:id]
50
-
51
- respond_to do |format|
52
- format.html
53
- end
54
- end
55
-
56
- def update
57
- @user = User.find params[:id]
58
-
59
- respond_to do |format|
60
- if @user.update_attributes(params[:user])
61
- format.html { redirect_to :action => :index, :notice => "User updated" }
62
- else
63
- flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :users])
64
- format.html { render :edit }
65
- end
66
- end
67
- end
68
-
69
- def destroy
70
- @user = User.find params[:id]
71
- @user.destroy
72
-
73
- respond_to do |format|
74
- format.html { redirect_to :action=>:index }
75
- end
76
- end
77
- end
78
- end