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
data/TODO CHANGED
@@ -1,3 +1,6 @@
1
+ * Integrate with ActiveModel instead of ActiveRecord
2
+ * Complete documentation
3
+ --
1
4
  * Update views to use the new flash convention [DONE]
2
5
  * flash[:notice] for information messages [DONE]
3
6
  * flash[:alert] for error messages [DONE]
@@ -1,5 +1,5 @@
1
1
  class AreasController < ApplicationController
2
- include Authentasaurus::AreasController
2
+ acts_as_areas
3
3
  require_read :index, :show
4
4
  require_write :new, :create, :edit, :update, :destroy
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class GroupsController < ApplicationController
2
- include Authentasaurus::GroupsController
2
+ acts_as_groups
3
3
  require_read :index, :show
4
4
  require_write :new, :create, :edit, :update, :destroy
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class PermissionsController < ApplicationController
2
- include Authentasaurus::PermissionsController
2
+ acts_as_permissions
3
3
  require_read :index, :show
4
4
  require_write :new, :create, :edit, :update, :destroy
5
5
  end
@@ -1,3 +1,3 @@
1
1
  class RecoveriesController < ApplicationController
2
- include Authentasaurus::RecoveriesController
2
+ acts_as_recoveries
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class RegistrationsController < ApplicationController
2
- include Authentasaurus::RegistrationsController
2
+ acts_as_registrations
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class SessionsController < ApplicationController
2
- include Authentasaurus::SessionsController
2
+ acts_as_sessions
3
3
  end
@@ -1,5 +1,5 @@
1
1
  class UserInvitationsController < ApplicationController
2
- include Authentasaurus::UserInvitationsController
2
+ acts_as_user_invitations
3
3
  require_read :index
4
4
  require_write :new, :create, :destroy
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class UsersController < ApplicationController
2
- include Authentasaurus::UsersController
2
+ acts_as_users
3
3
  require_read :index, :show
4
4
  require_write :new, :create, :edit, :update, :destroy
5
5
  end
@@ -1,3 +1,3 @@
1
1
  class ValidationsController < ApplicationController
2
- include Authentasaurus::ValidationsController
2
+ acts_as_validations
3
3
  end
data/app/models/area.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Area < ActiveRecord::Base
2
- include Authentasaurus::Models::Area
2
+ acts_as_area
3
3
  end
data/app/models/group.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Group < ActiveRecord::Base
2
- include Authentasaurus::Models::Group
2
+ acts_as_group
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Permission < ActiveRecord::Base
2
- include Authentasaurus::Models::Permission
2
+ acts_as_permission
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Recovery < ActiveRecord::Base
2
- include Authentasaurus::Models::Recovery
2
+ acts_as_recovery
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Session
2
- include Authentasaurus::Models::Session
2
+ include Authentasaurus::Ar::Models::Session
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class UserInvitation < ActiveRecord::Base
2
- include Authentasaurus::Models::UserInvitation
2
+ acts_as_user_invitation
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Validation < ActiveRecord::Base
2
- include Authentasaurus::Models::Validation
2
+ acts_as_validation
3
3
  end
@@ -1,65 +1,51 @@
1
- module Authentasaurus
2
- # NEVER EVER REMOVE THIS !!!
3
- require 'authentasaurus/railtie' if defined?(Rails)
4
- # Controller stubs
5
- require 'authentasaurus/areas_controller' if defined?(ActionController)
6
- require 'authentasaurus/groups_controller' if defined?(ActionController)
7
- require 'authentasaurus/permissions_controller' if defined?(ActionController)
8
- require 'authentasaurus/recoveries_controller' if defined?(ActionController)
9
- require 'authentasaurus/registrations_controller' if defined?(ActionController)
10
- require 'authentasaurus/sessions_controller' if defined?(ActionController)
11
- require 'authentasaurus/user_invitations_controller' if defined?(ActionController)
12
- require 'authentasaurus/users_controller' if defined?(ActionController)
13
- require 'authentasaurus/validations_controller' if defined?(ActionController)
14
- # Model stubs
15
- require 'authentasaurus/models/area' if defined?(ActiveRecord)
16
- require 'authentasaurus/models/group' if defined?(ActiveRecord)
17
- require 'authentasaurus/models/permission' if defined?(ActiveRecord)
18
- require 'authentasaurus/models/recovery' if defined?(ActiveRecord)
19
- require 'authentasaurus/models/session' if defined?(ActiveRecord)
20
- require 'authentasaurus/models/user_invitation' if defined?(ActiveRecord)
21
- require 'authentasaurus/models/validation' if defined?(ActiveRecord)
22
- # Overriders ^^
23
- require 'action_controller/authorization'
24
- require 'action_view/authorization'
25
- require 'active_record/authenticatable'
26
- require 'active_resource/authenticatable'
27
- require 'helpers/migrations'
28
- require 'helpers/routing'
1
+ module Authentasaurus
2
+ require 'authentasaurus/railtie' if defined?(Rails) # NEVER EVER REMOVE THIS LINE !!!
3
+ # Authorization Helpers
4
+ require 'authentasaurus/authorization'
5
+ # Controllers, Views and Routes helpers
6
+ require 'authentasaurus/ac/acts_as_overrider'
7
+ require 'authentasaurus/ac/routing'
8
+ # ActiveRecord And Migrations Helpers
9
+ require 'authentasaurus/ar/acts_as_overrider'
10
+ require 'authentasaurus/ar/authenticatable'
11
+ require 'authentasaurus/ar/migrations'
12
+ # ActiveResource Helpers
13
+ require 'authentasaurus/arel/authenticatable'
29
14
 
30
15
  if defined?(ActionController)
31
16
  class ActionController::Base
32
- include ActionController::Authorization
17
+ include Authentasaurus::Authorization::ActionController
18
+ include Authentasaurus::Ac::ActsAsOverrider
33
19
  end
34
20
 
35
21
  class ActionView::Base
36
- include ActionView::Authorization
22
+ include Authentasaurus::Authorization::ActionView
37
23
  end
38
24
 
39
25
  class ActionDispatch::Routing::Mapper
40
- include Routing
26
+ include Authentasaurus::Ac::Routing
41
27
  end
42
28
  end
43
29
 
44
30
  if defined?(ActiveRecord)
45
31
  class ActiveRecord::Base
46
- include ActiveRecord::Authenticatable
32
+ include Authentasaurus::Ar::Authenticatable
33
+ include Authentasaurus::Ar::ActsAsOverrider
47
34
  end
48
35
 
49
36
  class ActiveRecord::ConnectionAdapters::AbstractAdapter
50
- include Migrations::Tables
37
+ include Authentasaurus::Ar::Migrations::Tables
51
38
  end
52
39
 
53
40
  class ActiveRecord::ConnectionAdapters::TableDefinition
54
- include Migrations::Columns
41
+ include Authentasaurus::Ar::Migrations::Columns
55
42
  end
56
43
  end
57
44
 
58
45
  if defined?(ActiveResource)
59
46
  class ActiveResource::Base
60
47
  class_inheritable_accessor :sync, :sync_to
61
- include ActiveResource::Authenticatable
48
+ include Authentasaurus::Arel::Authenticatable
62
49
  end
63
50
  end
64
-
65
51
  end
@@ -0,0 +1,47 @@
1
+ module Authentasaurus::Ac
2
+ Dir[File.dirname(__FILE__) + '/controllers/*.rb'].each {|file| require file }
3
+
4
+ module ActsAsOverrider
5
+ def self.included(base)
6
+ base.send :extend, ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def acts_as_areas
11
+ include Authentasaurus::Ac::Controllers::AreasController
12
+ end
13
+
14
+ def acts_as_groups
15
+ include Authentasaurus::Ac::Controllers::GroupsController
16
+ end
17
+
18
+ def acts_as_permissions
19
+ include Authentasaurus::Ac::Controllers::PermissionsController
20
+ end
21
+
22
+ def acts_as_recoveries
23
+ include Authentasaurus::Ac::Controllers::RecoveriesController
24
+ end
25
+
26
+ def acts_as_registrations
27
+ include Authentasaurus::Ac::Controllers::RegistrationsController
28
+ end
29
+
30
+ def acts_as_sessions
31
+ include Authentasaurus::Ac::Controllers::SessionsController
32
+ end
33
+
34
+ def acts_as_user_invitations
35
+ include Authentasaurus::Ac::Controllers::UserInvitationsController
36
+ end
37
+
38
+ def acts_as_users
39
+ include Authentasaurus::Ac::Controllers::UsersController
40
+ end
41
+
42
+ def acts_as_validations
43
+ include Authentasaurus::Ac::Controllers::ValidationsController
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,80 @@
1
+ module Authentasaurus::Ac::Controllers
2
+ module AreasController
3
+ def self.included(base) # :nodoc:
4
+ base.send :extend, ClassMethods
5
+ base.send :include, InstanceMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def index
13
+ @areas= Area.find :all
14
+
15
+ respond_to do |format|
16
+ format.html
17
+ end
18
+ end
19
+
20
+ def show
21
+ @area = Area.find params[:id]
22
+
23
+ respond_to do |format|
24
+ format.html
25
+ end
26
+ end
27
+
28
+ def new
29
+ @area = Area.new
30
+
31
+ respond_to do |format|
32
+ format.html
33
+ end
34
+ end
35
+
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
46
+ end
47
+ end
48
+
49
+ def edit
50
+ @area = Area.find params[:id]
51
+
52
+ respond_to do |format|
53
+ format.html
54
+ end
55
+ end
56
+
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
67
+ end
68
+ end
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
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,81 @@
1
+ module Authentasaurus::Ac::Controllers
2
+ module GroupsController
3
+ def self.included(base) # :nodoc:
4
+ base.send :extend, ClassMethods
5
+ base.send :include, InstanceMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def index
13
+ @groups = Group.find :all
14
+
15
+ respond_to do |format|
16
+ format.html
17
+ end
18
+ end
19
+
20
+ def show
21
+ @group = Group.find params[:id]
22
+
23
+ respond_to do |format|
24
+ format.html
25
+ end
26
+ end
27
+
28
+ def new
29
+ @group = Group.new
30
+
31
+ respond_to do |format|
32
+ format.html
33
+ end
34
+ end
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
46
+ end
47
+ end
48
+
49
+ def edit
50
+ @group = Group.find params[:id]
51
+
52
+ respond_to do |format|
53
+ format.html
54
+ end
55
+ end
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
67
+ end
68
+
69
+ end
70
+
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
+ end
80
+ end
81
+ end
@@ -0,0 +1,81 @@
1
+ module Authentasaurus::Ac::Controllers
2
+ module PermissionsController
3
+ def self.included(base) # :nodoc:
4
+ base.send :extend, ClassMethods
5
+ base.send :include, InstanceMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def index
13
+ @permissions = Permission.find :all
14
+
15
+ respond_to do |format|
16
+ format.html
17
+ end
18
+ end
19
+
20
+ def show
21
+ @permission = Permission.find params[:id]
22
+
23
+ respond_to do |format|
24
+ format.html
25
+ end
26
+ end
27
+
28
+ def new
29
+ @permission = Permission.new
30
+
31
+ respond_to do |format|
32
+ format.html
33
+ end
34
+ end
35
+
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
46
+ end
47
+ end
48
+
49
+ def edit
50
+ @permission = Permission.find params[:id]
51
+
52
+ respond_to do |format|
53
+ format.html
54
+ end
55
+ end
56
+
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
68
+ end
69
+ end
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
78
+ end
79
+ end
80
+ end
81
+ end