lockdown 1.6.5 → 2.0.0
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/README.txt +8 -5
 - data/Rakefile +43 -26
 - data/lib/lockdown/access.rb +108 -0
 - data/lib/lockdown/configuration.rb +201 -0
 - data/lib/lockdown/database.rb +31 -36
 - data/lib/lockdown/delivery.rb +26 -0
 - data/lib/lockdown/errors.rb +3 -7
 - data/lib/lockdown/frameworks/rails/controller.rb +21 -59
 - data/lib/lockdown/frameworks/rails/view.rb +1 -1
 - data/lib/lockdown/frameworks/rails.rb +7 -43
 - data/lib/lockdown/helper.rb +14 -85
 - data/lib/lockdown/orms/active_record.rb +7 -9
 - data/lib/lockdown/permission.rb +37 -203
 - data/lib/lockdown/resource.rb +54 -0
 - data/lib/lockdown/session.rb +16 -25
 - data/lib/lockdown/user_group.rb +16 -0
 - data/lib/lockdown.rb +15 -60
 - data/lockdown.gemspec +29 -69
 - data/test/helper.rb +9 -0
 - data/test/lockdown/test_access.rb +80 -0
 - data/test/lockdown/test_configuration.rb +194 -0
 - data/test/lockdown/test_delivery.rb +163 -0
 - data/test/lockdown/test_helper.rb +33 -0
 - data/test/lockdown/test_permission.rb +73 -0
 - data/test/lockdown/test_resource.rb +47 -0
 - data/test/lockdown/test_session.rb +31 -0
 - data/test/lockdown/test_user_group.rb +17 -0
 - data/test/test_lockdown.rb +11 -0
 - metadata +41 -78
 - data/lib/lockdown/context.rb +0 -41
 - data/lib/lockdown/references.rb +0 -19
 - data/lib/lockdown/rspec_helper.rb +0 -118
 - data/lib/lockdown/rules.rb +0 -372
 - data/lib/lockdown/system.rb +0 -58
 - data/rails_generators/lockdown/lockdown_generator.rb +0 -274
 - data/rails_generators/lockdown/templates/app/controllers/permissions_controller.rb +0 -22
 - data/rails_generators/lockdown/templates/app/controllers/sessions_controller.rb +0 -39
 - data/rails_generators/lockdown/templates/app/controllers/user_groups_controller.rb +0 -122
 - data/rails_generators/lockdown/templates/app/controllers/users_controller.rb +0 -117
 - data/rails_generators/lockdown/templates/app/helpers/permissions_helper.rb +0 -2
 - data/rails_generators/lockdown/templates/app/helpers/user_groups_helper.rb +0 -2
 - data/rails_generators/lockdown/templates/app/helpers/users_helper.rb +0 -2
 - data/rails_generators/lockdown/templates/app/models/permission.rb +0 -13
 - data/rails_generators/lockdown/templates/app/models/profile.rb +0 -10
 - data/rails_generators/lockdown/templates/app/models/user.rb +0 -95
 - data/rails_generators/lockdown/templates/app/models/user_group.rb +0 -15
 - data/rails_generators/lockdown/templates/app/views/permissions/index.html.erb +0 -16
 - data/rails_generators/lockdown/templates/app/views/permissions/show.html.erb +0 -26
 - data/rails_generators/lockdown/templates/app/views/sessions/new.html.erb +0 -12
 - data/rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb +0 -33
 - data/rails_generators/lockdown/templates/app/views/user_groups/index.html.erb +0 -20
 - data/rails_generators/lockdown/templates/app/views/user_groups/new.html.erb +0 -31
 - data/rails_generators/lockdown/templates/app/views/user_groups/show.html.erb +0 -29
 - data/rails_generators/lockdown/templates/app/views/users/edit.html.erb +0 -51
 - data/rails_generators/lockdown/templates/app/views/users/index.html.erb +0 -22
 - data/rails_generators/lockdown/templates/app/views/users/new.html.erb +0 -50
 - data/rails_generators/lockdown/templates/app/views/users/show.html.erb +0 -33
 - data/rails_generators/lockdown/templates/config/initializers/lockit.rb +0 -1
 - data/rails_generators/lockdown/templates/db/migrate/create_admin_user.rb +0 -17
 - data/rails_generators/lockdown/templates/db/migrate/create_permissions.rb +0 -19
 - data/rails_generators/lockdown/templates/db/migrate/create_profiles.rb +0 -26
 - data/rails_generators/lockdown/templates/db/migrate/create_user_groups.rb +0 -19
 - data/rails_generators/lockdown/templates/db/migrate/create_users.rb +0 -17
 - data/rails_generators/lockdown/templates/lib/lockdown/README +0 -42
 - data/rails_generators/lockdown/templates/lib/lockdown/init.rb +0 -131
 - data/spec/lockdown/context_spec.rb +0 -191
 - data/spec/lockdown/database_spec.rb +0 -162
 - data/spec/lockdown/frameworks/rails/controller_spec.rb +0 -215
 - data/spec/lockdown/frameworks/rails/view_spec.rb +0 -96
 - data/spec/lockdown/frameworks/rails_spec.rb +0 -163
 - data/spec/lockdown/permission_spec.rb +0 -156
 - data/spec/lockdown/rspec_helper_spec.rb +0 -40
 - data/spec/lockdown/rules_spec.rb +0 -245
 - data/spec/lockdown/session_spec.rb +0 -112
 - data/spec/lockdown/system_spec.rb +0 -51
 - data/spec/lockdown_spec.rb +0 -19
 - data/spec/rcov.opts +0 -5
 - data/spec/spec.opts +0 -3
 - data/spec/spec_helper.rb +0 -8
 
| 
         @@ -1,95 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'digest/sha1'
         
     | 
| 
       2 
     | 
    
         
            -
            class User < ActiveRecord::Base
         
     | 
| 
       3 
     | 
    
         
            -
              has_and_belongs_to_many :user_groups
         
     | 
| 
       4 
     | 
    
         
            -
              belongs_to :profile
         
     | 
| 
       5 
     | 
    
         
            -
              
         
     | 
| 
       6 
     | 
    
         
            -
              # Virtual attributes
         
     | 
| 
       7 
     | 
    
         
            -
              attr_accessor :password
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              validates_presence_of     :login
         
     | 
| 
       10 
     | 
    
         
            -
              validates_presence_of     :password,                   :if => :password_required?
         
     | 
| 
       11 
     | 
    
         
            -
              validates_presence_of     :password_confirmation,      :if => :password_required?
         
     | 
| 
       12 
     | 
    
         
            -
              validates_length_of       :password, :within => 4..40, :if => :password_required?
         
     | 
| 
       13 
     | 
    
         
            -
              validates_confirmation_of :password,                   :if => :password_required?
         
     | 
| 
       14 
     | 
    
         
            -
              validates_length_of       :login,    :within => 3..40
         
     | 
| 
       15 
     | 
    
         
            -
              validates_uniqueness_of   :login, :case_sensitive => false
         
     | 
| 
       16 
     | 
    
         
            -
              
         
     | 
| 
       17 
     | 
    
         
            -
            	before_save :encrypt_password
         
     | 
| 
       18 
     | 
    
         
            -
            	before_save :save_profile
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              attr_accessible :login, :password, :password_confirmation, 
         
     | 
| 
       21 
     | 
    
         
            -
                              :first_name, :last_name, :email
         
     | 
| 
       22 
     | 
    
         
            -
              
         
     | 
| 
       23 
     | 
    
         
            -
              # Authenticates a user by their login name and unencrypted password.  
         
     | 
| 
       24 
     | 
    
         
            -
              # Returns the user or nil.
         
     | 
| 
       25 
     | 
    
         
            -
              def self.authenticate(login, password)
         
     | 
| 
       26 
     | 
    
         
            -
                u = find :first, :conditions => ['login = ?', login] # need to get the salt
         
     | 
| 
       27 
     | 
    
         
            -
                u && u.authenticated?(password) ? u : nil
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              # Encrypts some data with the salt.
         
     | 
| 
       31 
     | 
    
         
            -
              def self.encrypt(password, salt)
         
     | 
| 
       32 
     | 
    
         
            -
                Digest::SHA1.hexdigest("--#{salt}--#{password}--")
         
     | 
| 
       33 
     | 
    
         
            -
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
              # Encrypts the password with the user salt
         
     | 
| 
       36 
     | 
    
         
            -
              def encrypt(password)
         
     | 
| 
       37 
     | 
    
         
            -
                self.class.encrypt(password, salt)
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              def authenticated?(password)
         
     | 
| 
       41 
     | 
    
         
            -
                crypted_password == encrypt(password)
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
              
         
     | 
| 
       44 
     | 
    
         
            -
              def full_name
         
     | 
| 
       45 
     | 
    
         
            -
                first_name + " " + last_name
         
     | 
| 
       46 
     | 
    
         
            -
              end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
              # Profile information
         
     | 
| 
       49 
     | 
    
         
            -
              def first_name
         
     | 
| 
       50 
     | 
    
         
            -
                user_profile.first_name
         
     | 
| 
       51 
     | 
    
         
            -
              end
         
     | 
| 
       52 
     | 
    
         
            -
              
         
     | 
| 
       53 
     | 
    
         
            -
              def first_name=(string)
         
     | 
| 
       54 
     | 
    
         
            -
                user_profile.first_name = string
         
     | 
| 
       55 
     | 
    
         
            -
              end
         
     | 
| 
       56 
     | 
    
         
            -
              
         
     | 
| 
       57 
     | 
    
         
            -
              def last_name
         
     | 
| 
       58 
     | 
    
         
            -
                user_profile.last_name
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
              
         
     | 
| 
       61 
     | 
    
         
            -
              def last_name=(string)
         
     | 
| 
       62 
     | 
    
         
            -
                user_profile.last_name = string
         
     | 
| 
       63 
     | 
    
         
            -
              end
         
     | 
| 
       64 
     | 
    
         
            -
              
         
     | 
| 
       65 
     | 
    
         
            -
              def email
         
     | 
| 
       66 
     | 
    
         
            -
                user_profile.email
         
     | 
| 
       67 
     | 
    
         
            -
              end
         
     | 
| 
       68 
     | 
    
         
            -
              
         
     | 
| 
       69 
     | 
    
         
            -
              def email=(string)
         
     | 
| 
       70 
     | 
    
         
            -
                user_profile.email = string
         
     | 
| 
       71 
     | 
    
         
            -
              end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
              def user_profile
         
     | 
| 
       74 
     | 
    
         
            -
                self.profile || self.profile = Profile.new
         
     | 
| 
       75 
     | 
    
         
            -
              end
         
     | 
| 
       76 
     | 
    
         
            -
              
         
     | 
| 
       77 
     | 
    
         
            -
              protected
         
     | 
| 
       78 
     | 
    
         
            -
                  
         
     | 
| 
       79 
     | 
    
         
            -
              def encrypt_password
         
     | 
| 
       80 
     | 
    
         
            -
                return if password.blank?
         
     | 
| 
       81 
     | 
    
         
            -
                if new_record?
         
     | 
| 
       82 
     | 
    
         
            -
                  self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") 
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
                self.crypted_password = encrypt(password)
         
     | 
| 
       85 
     | 
    
         
            -
              end
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
              def save_profile
         
     | 
| 
       88 
     | 
    
         
            -
                profile.save
         
     | 
| 
       89 
     | 
    
         
            -
              end
         
     | 
| 
       90 
     | 
    
         
            -
              
         
     | 
| 
       91 
     | 
    
         
            -
              def password_required?
         
     | 
| 
       92 
     | 
    
         
            -
                (crypted_password.blank? || !password.blank?)
         
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
                
         
     | 
| 
       95 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,15 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class UserGroup < ActiveRecord::Base
         
     | 
| 
       2 
     | 
    
         
            -
              has_and_belongs_to_many :permissions
         
     | 
| 
       3 
     | 
    
         
            -
              has_and_belongs_to_many :users
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              validates_presence_of :name
         
     | 
| 
       6 
     | 
    
         
            -
              
         
     | 
| 
       7 
     | 
    
         
            -
            	def all_users
         
     | 
| 
       8 
     | 
    
         
            -
            		User.find_by_sql <<-SQL
         
     | 
| 
       9 
     | 
    
         
            -
            			select users.* 
         
     | 
| 
       10 
     | 
    
         
            -
            			from users, user_groups_users
         
     | 
| 
       11 
     | 
    
         
            -
            			where users.id = user_groups_users.user_id 
         
     | 
| 
       12 
     | 
    
         
            -
            			and user_groups_users.user_group_id = #{self.id}
         
     | 
| 
       13 
     | 
    
         
            -
                SQL
         
     | 
| 
       14 
     | 
    
         
            -
            	end
         
     | 
| 
       15 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,16 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>Listing Permissions</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <table>
         
     | 
| 
       4 
     | 
    
         
            -
              <tr>
         
     | 
| 
       5 
     | 
    
         
            -
                <th>Name</th>
         
     | 
| 
       6 
     | 
    
         
            -
              </tr>
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            <%% for permission in @permissions %>
         
     | 
| 
       9 
     | 
    
         
            -
              <tr>
         
     | 
| 
       10 
     | 
    
         
            -
                <td><%%=h permission.name %></td>
         
     | 
| 
       11 
     | 
    
         
            -
                <td><%%= link_to 'Show', <%= namespace.blank? ? 'permission_path(permission)' : "#{namespace}_permission_path(permission)" %> %></td>
         
     | 
| 
       12 
     | 
    
         
            -
              </tr>
         
     | 
| 
       13 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       14 
     | 
    
         
            -
            </table>
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            <br />
         
     | 
| 
         @@ -1,26 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <p>
         
     | 
| 
       2 
     | 
    
         
            -
              <b>Name</b><br />
         
     | 
| 
       3 
     | 
    
         
            -
              <%%= h @permission.name %>
         
     | 
| 
       4 
     | 
    
         
            -
            </p>
         
     | 
| 
       5 
     | 
    
         
            -
            <p>
         
     | 
| 
       6 
     | 
    
         
            -
              <b>Access rights:</b><br />
         
     | 
| 
       7 
     | 
    
         
            -
              <%%
         
     | 
| 
       8 
     | 
    
         
            -
                Lockdown::System.access_rights_for_permission(@permission).each do |access_right| 
         
     | 
| 
       9 
     | 
    
         
            -
              %>
         
     | 
| 
       10 
     | 
    
         
            -
                <%%= access_right %><br/>
         
     | 
| 
       11 
     | 
    
         
            -
              <%%
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              %>
         
     | 
| 
       14 
     | 
    
         
            -
            </p>
         
     | 
| 
       15 
     | 
    
         
            -
            <p>
         
     | 
| 
       16 
     | 
    
         
            -
              <b>Users with permission:</b><br />
         
     | 
| 
       17 
     | 
    
         
            -
              <%%
         
     | 
| 
       18 
     | 
    
         
            -
                @permission.all_users.each do |user| 
         
     | 
| 
       19 
     | 
    
         
            -
              %>
         
     | 
| 
       20 
     | 
    
         
            -
                  <%%= link_to_or_show(user.full_name, <%= namespace.blank? ? 'user' : "#{namespace}_user_path(user)" %>) %><br/>
         
     | 
| 
       21 
     | 
    
         
            -
              <%%
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
              %>
         
     | 
| 
       24 
     | 
    
         
            -
            </p>
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? 'permissions_path' : "#{namespace}_permissions_path" %> %>
         
     | 
| 
         @@ -1,12 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <%%= flash[:notice] if flash[:notice] %>
         
     | 
| 
       2 
     | 
    
         
            -
            <%%= flash[:error] if flash[:error] %>
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            <%% form_tag sessions_path  do -%>
         
     | 
| 
       5 
     | 
    
         
            -
            	<p><label for="login">Login</label><br/>
         
     | 
| 
       6 
     | 
    
         
            -
            	<%%= text_field_tag 'login' %></p>
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            	<p><label for="password">Password</label><br/>
         
     | 
| 
       9 
     | 
    
         
            -
            	<%%= password_field_tag 'password' %></p>
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            	<p><%%= submit_tag 'Log in' %></p>
         
     | 
| 
       12 
     | 
    
         
            -
            <%% end -%>
         
     | 
| 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>Editing User Group</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <%% form_for(<%= namespace.blank? ? '@user_group' : "[:#{namespace}, @user_group]"  %>) do |f| %>
         
     | 
| 
       4 
     | 
    
         
            -
              <%%= f.error_messages %>
         
     | 
| 
       5 
     | 
    
         
            -
              <p>
         
     | 
| 
       6 
     | 
    
         
            -
                <b>Name</b><br />
         
     | 
| 
       7 
     | 
    
         
            -
                <%%= f.text_field :name %>
         
     | 
| 
       8 
     | 
    
         
            -
              </p>
         
     | 
| 
       9 
     | 
    
         
            -
              <p>
         
     | 
| 
       10 
     | 
    
         
            -
                <b>Permissions</b><br />
         
     | 
| 
       11 
     | 
    
         
            -
                <ul style="list-style: none;">
         
     | 
| 
       12 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       13 
     | 
    
         
            -
                    @all_permissions.each_with_index do |perm,i|
         
     | 
| 
       14 
     | 
    
         
            -
                      input_id = "perm_#{perm.id}"
         
     | 
| 
       15 
     | 
    
         
            -
                      checked = (@user_group.permission_ids.include?(perm.id) ? "checked" : "")
         
     | 
| 
       16 
     | 
    
         
            -
                  %>
         
     | 
| 
       17 
     | 
    
         
            -
                      <li id="li_<%%= input_id %>">
         
     | 
| 
       18 
     | 
    
         
            -
                        <label for="<%%= input_id %>">
         
     | 
| 
       19 
     | 
    
         
            -
                        <input id="<%%= input_id %>" name="<%%= input_id %>" type="checkbox" <%%= checked %>/>  <%%= perm.name %>
         
     | 
| 
       20 
     | 
    
         
            -
                        </label>
         
     | 
| 
       21 
     | 
    
         
            -
                      </li>
         
     | 
| 
       22 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       23 
     | 
    
         
            -
                    end
         
     | 
| 
       24 
     | 
    
         
            -
                  %>
         
     | 
| 
       25 
     | 
    
         
            -
                </ul>
         
     | 
| 
       26 
     | 
    
         
            -
              </p>
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              <p> <%%= f.submit "Update" %> </p>
         
     | 
| 
       29 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            <%%= link_to 'Show', <%= namespace.blank? ? '@user_group' : "#{namespace}_user_group_path(@user_group)" %> %> |
         
     | 
| 
       33 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? 'user_groups_path' : "#{namespace}_user_groups_path" %> %>
         
     | 
| 
         @@ -1,20 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>Listing User Groups</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <table>
         
     | 
| 
       4 
     | 
    
         
            -
              <tr>
         
     | 
| 
       5 
     | 
    
         
            -
                <th>Name</th>
         
     | 
| 
       6 
     | 
    
         
            -
              </tr>
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            <%% for user_group in @user_groups %>
         
     | 
| 
       9 
     | 
    
         
            -
              <tr>
         
     | 
| 
       10 
     | 
    
         
            -
                <td><%%=h user_group.name %></td>
         
     | 
| 
       11 
     | 
    
         
            -
                <td><%%= link_to 'Show', <%= namespace.blank? ? "user_group_path(user_group)" : "#{namespace}_user_group_path(user_group)" %> %></td>
         
     | 
| 
       12 
     | 
    
         
            -
                <td><%%= link_to('Edit', <%= namespace.blank? ? "edit_user_group_path(user_group)" : "edit_#{namespace}_user_group_path(user_group)" %>) unless Lockdown::System.has_user_group?(user_group) %></td>
         
     | 
| 
       13 
     | 
    
         
            -
                <td><%%= link_to('Destroy',<%= namespace.blank? ? "user_group_path(user_group)" : "#{namespace}_user_group_path(user_group)" %>, :confirm => 'Are you sure?', :method => :delete) unless Lockdown::System.has_user_group?(user_group) %></td>
         
     | 
| 
       14 
     | 
    
         
            -
              </tr>
         
     | 
| 
       15 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       16 
     | 
    
         
            -
            </table>
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            <br />
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            <%%= link_to 'New User Group', <%= namespace.blank? ? "new_user_group_path" : "new_#{namespace}_user_group_path" %> %>
         
     | 
| 
         @@ -1,31 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>New User Group</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <%% form_for(<%= namespace.blank? ? '@user_group' : "[:#{namespace}, @user_group]"  %>) do |f| %>
         
     | 
| 
       4 
     | 
    
         
            -
              <%%= f.error_messages %>
         
     | 
| 
       5 
     | 
    
         
            -
              <p>
         
     | 
| 
       6 
     | 
    
         
            -
                <b>Name</b><br />
         
     | 
| 
       7 
     | 
    
         
            -
                <%%= f.text_field :name %>
         
     | 
| 
       8 
     | 
    
         
            -
              </p>
         
     | 
| 
       9 
     | 
    
         
            -
              <p>
         
     | 
| 
       10 
     | 
    
         
            -
                <b>Permissions</b><br />
         
     | 
| 
       11 
     | 
    
         
            -
                <ul style="list-style: none;">
         
     | 
| 
       12 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       13 
     | 
    
         
            -
                    @all_permissions.each_with_index do |perm,i|
         
     | 
| 
       14 
     | 
    
         
            -
                      input_id = "perm_#{perm.id}"
         
     | 
| 
       15 
     | 
    
         
            -
                      checked = (@user_group.permission_ids.include?(perm.id) ? "checked" : "")          
         
     | 
| 
       16 
     | 
    
         
            -
                  %>
         
     | 
| 
       17 
     | 
    
         
            -
                      <li id="li_<%%= input_id %>">
         
     | 
| 
       18 
     | 
    
         
            -
                        <label for="<%%= input_id %>">
         
     | 
| 
       19 
     | 
    
         
            -
                          <input id="<%%= input_id %>" name="<%%= input_id %>" type="checkbox" <%%= checked %>/>  <%%= perm.name %>
         
     | 
| 
       20 
     | 
    
         
            -
                        </label>
         
     | 
| 
       21 
     | 
    
         
            -
                      </li>
         
     | 
| 
       22 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       23 
     | 
    
         
            -
                    end
         
     | 
| 
       24 
     | 
    
         
            -
                  %>
         
     | 
| 
       25 
     | 
    
         
            -
                </ul>
         
     | 
| 
       26 
     | 
    
         
            -
              </p>
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              <p> <%%= f.submit "Create" %> </p>
         
     | 
| 
       29 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? 'user_groups_path' : "#{namespace}_user_groups_path" %> %>
         
     | 
| 
         @@ -1,29 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <p>
         
     | 
| 
       2 
     | 
    
         
            -
              <b>Name</b><br />
         
     | 
| 
       3 
     | 
    
         
            -
              <%%= h @user_group.name %>
         
     | 
| 
       4 
     | 
    
         
            -
            </p>
         
     | 
| 
       5 
     | 
    
         
            -
            <p>
         
     | 
| 
       6 
     | 
    
         
            -
              <b>Permissions</b><br />
         
     | 
| 
       7 
     | 
    
         
            -
              <%%
         
     | 
| 
       8 
     | 
    
         
            -
                @user_group.permissions.each do |perm| 
         
     | 
| 
       9 
     | 
    
         
            -
              %>
         
     | 
| 
       10 
     | 
    
         
            -
                  <%%= perm.name %><br/>
         
     | 
| 
       11 
     | 
    
         
            -
              <%%
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              %>
         
     | 
| 
       14 
     | 
    
         
            -
            </p>
         
     | 
| 
       15 
     | 
    
         
            -
            <p>
         
     | 
| 
       16 
     | 
    
         
            -
            	<b>Users in user group:</b><br />
         
     | 
| 
       17 
     | 
    
         
            -
            	<%%
         
     | 
| 
       18 
     | 
    
         
            -
            	  @user_group.all_users.each do |user| 
         
     | 
| 
       19 
     | 
    
         
            -
            	%>
         
     | 
| 
       20 
     | 
    
         
            -
            	    <%%= link_to_or_show(user.full_name, <%= namespace.blank? ? 'user' : "#{namespace}_user_path(user)" %>) %><br/>
         
     | 
| 
       21 
     | 
    
         
            -
            	<%%
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
            	%>
         
     | 
| 
       24 
     | 
    
         
            -
            </p>
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            <%% unless Lockdown::System.has_user_group?(@user_group) %>
         
     | 
| 
       27 
     | 
    
         
            -
              <%%= link_to 'Edit', <%= namespace.blank? ? 'edit_user_group_path(@user_group)' : "edit_#{namespace}_user_group_path(@user_group)" %> %> |
         
     | 
| 
       28 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       29 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? 'user_groups_path' : "#{namespace}_user_groups_path" %> %>
         
     | 
| 
         @@ -1,51 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>Editing User</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <%% form_for(<%= namespace.blank? ? "@user" : "[:#{namespace}, @user]" %>) do |f| %>
         
     | 
| 
       4 
     | 
    
         
            -
              <%%= f.error_messages %>
         
     | 
| 
       5 
     | 
    
         
            -
              <p>
         
     | 
| 
       6 
     | 
    
         
            -
                <b>First name</b><br />
         
     | 
| 
       7 
     | 
    
         
            -
                <%%= f.text_field :first_name %>
         
     | 
| 
       8 
     | 
    
         
            -
              </p>
         
     | 
| 
       9 
     | 
    
         
            -
              <p>
         
     | 
| 
       10 
     | 
    
         
            -
                <b>Last name</b><br />
         
     | 
| 
       11 
     | 
    
         
            -
                <%%= f.text_field :last_name %>
         
     | 
| 
       12 
     | 
    
         
            -
              </p>
         
     | 
| 
       13 
     | 
    
         
            -
              <p>
         
     | 
| 
       14 
     | 
    
         
            -
                <b>Email</b><br />
         
     | 
| 
       15 
     | 
    
         
            -
                <%%= f.text_field :email %>
         
     | 
| 
       16 
     | 
    
         
            -
              </p>
         
     | 
| 
       17 
     | 
    
         
            -
              <p>
         
     | 
| 
       18 
     | 
    
         
            -
              	<b>Login</b><br />
         
     | 
| 
       19 
     | 
    
         
            -
                <%%= f.text_field :login %>
         
     | 
| 
       20 
     | 
    
         
            -
              </p>
         
     | 
| 
       21 
     | 
    
         
            -
              <p>
         
     | 
| 
       22 
     | 
    
         
            -
                <b>Password</b><br />
         
     | 
| 
       23 
     | 
    
         
            -
                <%%= f.password_field :password %>
         
     | 
| 
       24 
     | 
    
         
            -
              </p>
         
     | 
| 
       25 
     | 
    
         
            -
              <p>
         
     | 
| 
       26 
     | 
    
         
            -
                <b>Password confirmation</b><br />
         
     | 
| 
       27 
     | 
    
         
            -
                <%%= f.password_field :password_confirmation %>
         
     | 
| 
       28 
     | 
    
         
            -
              </p>
         
     | 
| 
       29 
     | 
    
         
            -
              <p>
         
     | 
| 
       30 
     | 
    
         
            -
                <b>User Groups</b><br />
         
     | 
| 
       31 
     | 
    
         
            -
                <ul style="list-style: none;">
         
     | 
| 
       32 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       33 
     | 
    
         
            -
                    @user_groups_for_user.each_with_index do |ug,i|
         
     | 
| 
       34 
     | 
    
         
            -
                      input_id = "ug_#{ug.id}"
         
     | 
| 
       35 
     | 
    
         
            -
                      checked = (@user.user_group_ids.include?(ug.id) ? "checked" : "")          
         
     | 
| 
       36 
     | 
    
         
            -
                  %>
         
     | 
| 
       37 
     | 
    
         
            -
                      <li id="li_<%%= input_id %>">
         
     | 
| 
       38 
     | 
    
         
            -
                        <label for="<%%= input_id %>">
         
     | 
| 
       39 
     | 
    
         
            -
                        <input id="<%%= input_id %>" name="<%%= input_id %>" type="checkbox" <%%= checked %>/>  <%%= ug.name %>
         
     | 
| 
       40 
     | 
    
         
            -
                        </label>
         
     | 
| 
       41 
     | 
    
         
            -
                      </li>
         
     | 
| 
       42 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       43 
     | 
    
         
            -
                    end
         
     | 
| 
       44 
     | 
    
         
            -
                  %>
         
     | 
| 
       45 
     | 
    
         
            -
                </ul>
         
     | 
| 
       46 
     | 
    
         
            -
              </p>
         
     | 
| 
       47 
     | 
    
         
            -
              <p> <%%= f.submit "Update" %> </p>
         
     | 
| 
       48 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            <%%= link_to 'Show', <%= namespace.blank? ? "user_path(@user)" : "#{namespace}_user_path(@user)" %> %> |
         
     | 
| 
       51 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? "users_path" : "#{namespace}_users_path" %> %>
         
     | 
| 
         @@ -1,22 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>Listing Users</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <table>
         
     | 
| 
       4 
     | 
    
         
            -
              <tr>
         
     | 
| 
       5 
     | 
    
         
            -
                <th>Login</th>
         
     | 
| 
       6 
     | 
    
         
            -
                <th>Name</th>
         
     | 
| 
       7 
     | 
    
         
            -
              </tr>
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            <%% @users.each do |user| %>
         
     | 
| 
       10 
     | 
    
         
            -
              <tr>
         
     | 
| 
       11 
     | 
    
         
            -
                <td><%%=h user.login %></td>
         
     | 
| 
       12 
     | 
    
         
            -
                <td><%%=h user.full_name %></td>
         
     | 
| 
       13 
     | 
    
         
            -
                <td><%%= link_to 'Show', <%= namespace.blank? ? "user_path(user)" : "#{namespace}_user_path(user)" %> %></td>
         
     | 
| 
       14 
     | 
    
         
            -
                <td><%%= link_to 'Edit', <%= namespace.blank? ? "edit_user_path(user)" : "edit_#{namespace}_user_path(user)" %> %></td>
         
     | 
| 
       15 
     | 
    
         
            -
                <td><%%= link_to 'Destroy', <%= namespace.blank? ? "user_path(user)" : "#{namespace}_user_path(user)" %>, :confirm => 'Are you sure?', :method => :delete %></td>
         
     | 
| 
       16 
     | 
    
         
            -
              </tr>
         
     | 
| 
       17 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       18 
     | 
    
         
            -
            </table>
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            <br />
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            <%%= link_to 'New User', <%= namespace.blank? ? "new_user_path" : "new_#{namespace}_user_path" %> %>
         
     | 
| 
         @@ -1,50 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>New User</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <%% form_for(<%= namespace.blank? ? "@user" : "[:#{namespace}, @user]" %>) do |f| %>
         
     | 
| 
       4 
     | 
    
         
            -
              <%%= f.error_messages %>
         
     | 
| 
       5 
     | 
    
         
            -
              <p>
         
     | 
| 
       6 
     | 
    
         
            -
                <b>First name</b><br />
         
     | 
| 
       7 
     | 
    
         
            -
                <%%= f.text_field :first_name %>
         
     | 
| 
       8 
     | 
    
         
            -
              </p>
         
     | 
| 
       9 
     | 
    
         
            -
              <p>
         
     | 
| 
       10 
     | 
    
         
            -
                <b>Last name</b><br />
         
     | 
| 
       11 
     | 
    
         
            -
                <%%= f.text_field :last_name %>
         
     | 
| 
       12 
     | 
    
         
            -
              </p>
         
     | 
| 
       13 
     | 
    
         
            -
              <p>
         
     | 
| 
       14 
     | 
    
         
            -
                <b>Email</b><br />
         
     | 
| 
       15 
     | 
    
         
            -
                <%%= f.text_field :email %>
         
     | 
| 
       16 
     | 
    
         
            -
              </p>
         
     | 
| 
       17 
     | 
    
         
            -
              <p>
         
     | 
| 
       18 
     | 
    
         
            -
              	<b>Login</b><br />
         
     | 
| 
       19 
     | 
    
         
            -
                <%%= f.text_field :login %>
         
     | 
| 
       20 
     | 
    
         
            -
              </p>
         
     | 
| 
       21 
     | 
    
         
            -
              <p>
         
     | 
| 
       22 
     | 
    
         
            -
                <b>Password</b><br />
         
     | 
| 
       23 
     | 
    
         
            -
                <%%= f.password_field :password %>
         
     | 
| 
       24 
     | 
    
         
            -
              </p>
         
     | 
| 
       25 
     | 
    
         
            -
              <p>
         
     | 
| 
       26 
     | 
    
         
            -
                <b>Password confirmation</b><br />
         
     | 
| 
       27 
     | 
    
         
            -
                <%%= f.password_field :password_confirmation %>
         
     | 
| 
       28 
     | 
    
         
            -
              </p>
         
     | 
| 
       29 
     | 
    
         
            -
              <p>
         
     | 
| 
       30 
     | 
    
         
            -
                <b>User Groups</b><br />
         
     | 
| 
       31 
     | 
    
         
            -
                <ul style="list-style: none;">
         
     | 
| 
       32 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       33 
     | 
    
         
            -
                    @user_groups_for_user.each_with_index do |ug,i|
         
     | 
| 
       34 
     | 
    
         
            -
                      input_id = "ug_#{ug.id}"
         
     | 
| 
       35 
     | 
    
         
            -
                      checked = (@user.user_group_ids.include?(ug.id) ? "checked" : "")                    
         
     | 
| 
       36 
     | 
    
         
            -
                  %>
         
     | 
| 
       37 
     | 
    
         
            -
                      <li id="li_<%%= input_id %>">
         
     | 
| 
       38 
     | 
    
         
            -
                        <label for="<%%= input_id %>">
         
     | 
| 
       39 
     | 
    
         
            -
                        <input id="<%%= input_id %>" name="<%%= input_id %>" type="checkbox" <%%= checked %>/>  <%%= ug.name %>
         
     | 
| 
       40 
     | 
    
         
            -
                        </label>
         
     | 
| 
       41 
     | 
    
         
            -
                      </li>
         
     | 
| 
       42 
     | 
    
         
            -
                  <%% 
         
     | 
| 
       43 
     | 
    
         
            -
                    end
         
     | 
| 
       44 
     | 
    
         
            -
                  %>
         
     | 
| 
       45 
     | 
    
         
            -
                </ul>
         
     | 
| 
       46 
     | 
    
         
            -
              </p>
         
     | 
| 
       47 
     | 
    
         
            -
              <p> <%%= f.submit "Create" %> </p>
         
     | 
| 
       48 
     | 
    
         
            -
            <%% end %>
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? "users_path" : "#{namespace}_users_path" %> %>
         
     | 
| 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h1>Showing User</h1>
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            <p>
         
     | 
| 
       4 
     | 
    
         
            -
              <b>First name</b><br />
         
     | 
| 
       5 
     | 
    
         
            -
              <%%= h @user.first_name %>
         
     | 
| 
       6 
     | 
    
         
            -
            </p>
         
     | 
| 
       7 
     | 
    
         
            -
            <p>
         
     | 
| 
       8 
     | 
    
         
            -
              <b>Last name</b><br />
         
     | 
| 
       9 
     | 
    
         
            -
              <%%= h @user.last_name %>
         
     | 
| 
       10 
     | 
    
         
            -
            </p>
         
     | 
| 
       11 
     | 
    
         
            -
            <p>
         
     | 
| 
       12 
     | 
    
         
            -
              <b>Email</b><br />
         
     | 
| 
       13 
     | 
    
         
            -
              <%%= h @user.email %>
         
     | 
| 
       14 
     | 
    
         
            -
            </p>
         
     | 
| 
       15 
     | 
    
         
            -
            <p>
         
     | 
| 
       16 
     | 
    
         
            -
            	<b><span>L</span>ogin</b><br />
         
     | 
| 
       17 
     | 
    
         
            -
              <%%= h @user.login %>
         
     | 
| 
       18 
     | 
    
         
            -
            </p>
         
     | 
| 
       19 
     | 
    
         
            -
            <p>
         
     | 
| 
       20 
     | 
    
         
            -
              <b>User Groups</b><br />
         
     | 
| 
       21 
     | 
    
         
            -
              <ul style="list-style: none;">
         
     | 
| 
       22 
     | 
    
         
            -
                <%% 
         
     | 
| 
       23 
     | 
    
         
            -
                  @user.user_groups.each do |ug| 
         
     | 
| 
       24 
     | 
    
         
            -
                %>
         
     | 
| 
       25 
     | 
    
         
            -
                   <%%= h ug.name %> <br/>
         
     | 
| 
       26 
     | 
    
         
            -
                <%% 
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
                %>
         
     | 
| 
       29 
     | 
    
         
            -
              </ul>
         
     | 
| 
       30 
     | 
    
         
            -
            </p>
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            <%%= link_to 'Edit', <%= namespace.blank? ? "edit_user_path(@user)" : "edit_#{namespace}_user_path(@user)" %> %> |
         
     | 
| 
       33 
     | 
    
         
            -
            <%%= link_to 'Back', <%= namespace.blank? ? "users_path" : "#{namespace}_users_path" %> %>
         
     | 
| 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'lockdown'
         
     | 
| 
         @@ -1,17 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class CreateAdminUser < ActiveRecord::Migration
         
     | 
| 
       2 
     | 
    
         
            -
              def self.up
         
     | 
| 
       3 
     | 
    
         
            -
            		# TODO: Change the password
         
     | 
| 
       4 
     | 
    
         
            -
                u = User.create(:password => "password", 
         
     | 
| 
       5 
     | 
    
         
            -
                                :password_confirmation => "password", 
         
     | 
| 
       6 
     | 
    
         
            -
                                :first_name => "Administrator",
         
     | 
| 
       7 
     | 
    
         
            -
                                :last_name => "User",
         
     | 
| 
       8 
     | 
    
         
            -
                                :email => "administrator@a.com",
         
     | 
| 
       9 
     | 
    
         
            -
                                :login => "admin")
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            		Lockdown::System.make_user_administrator(u)
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
            	 
         
     | 
| 
       14 
     | 
    
         
            -
              def self.down
         
     | 
| 
       15 
     | 
    
         
            -
                #Nothing to see here...
         
     | 
| 
       16 
     | 
    
         
            -
            	end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,19 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class CreatePermissions < ActiveRecord::Migration
         
     | 
| 
       2 
     | 
    
         
            -
              def self.up
         
     | 
| 
       3 
     | 
    
         
            -
                create_table :permissions do |t|
         
     | 
| 
       4 
     | 
    
         
            -
                  t.string :name
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                  t.timestamps
         
     | 
| 
       7 
     | 
    
         
            -
                end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            		create_table :permissions_user_groups, :id => false do |t|
         
     | 
| 
       10 
     | 
    
         
            -
                  t.integer :permission_id
         
     | 
| 
       11 
     | 
    
         
            -
                  t.integer :user_group_id
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              def self.down
         
     | 
| 
       16 
     | 
    
         
            -
            		drop_table :permissions_user_groups
         
     | 
| 
       17 
     | 
    
         
            -
                drop_table :permissions
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,26 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class CreateProfiles < ActiveRecord::Migration
         
     | 
| 
       2 
     | 
    
         
            -
              def self.up
         
     | 
| 
       3 
     | 
    
         
            -
                create_table :profiles do |t|
         
     | 
| 
       4 
     | 
    
         
            -
                  t.string :first_name
         
     | 
| 
       5 
     | 
    
         
            -
                  t.string :last_name
         
     | 
| 
       6 
     | 
    
         
            -
                  t.string :email
         
     | 
| 
       7 
     | 
    
         
            -
                  t.integer :updated_by
         
     | 
| 
       8 
     | 
    
         
            -
                  t.boolean :is_disabled
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  t.timestamps
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            		# The System profile is used as the updated_by reference when records 
         
     | 
| 
       14 
     | 
    
         
            -
                # are created programatically and the responsible user cannot be determined 
         
     | 
| 
       15 
     | 
    
         
            -
                # or is simply not available.
         
     | 
| 
       16 
     | 
    
         
            -
            		# TODO: Change email address
         
     | 
| 
       17 
     | 
    
         
            -
            		Profile.create(:first_name => "System",
         
     | 
| 
       18 
     | 
    
         
            -
            										:last_name => "User",
         
     | 
| 
       19 
     | 
    
         
            -
            										:email => "system@a.com")
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              def self.down
         
     | 
| 
       24 
     | 
    
         
            -
                drop_table :profiles
         
     | 
| 
       25 
     | 
    
         
            -
              end
         
     | 
| 
       26 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,19 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class CreateUserGroups < ActiveRecord::Migration
         
     | 
| 
       2 
     | 
    
         
            -
              def self.up
         
     | 
| 
       3 
     | 
    
         
            -
                create_table :user_groups do |t|
         
     | 
| 
       4 
     | 
    
         
            -
                  t.string :name
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                  t.timestamps
         
     | 
| 
       7 
     | 
    
         
            -
                end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                create_table :user_groups_users, :id => false do |t|
         
     | 
| 
       10 
     | 
    
         
            -
                  t.integer :user_group_id
         
     | 
| 
       11 
     | 
    
         
            -
                  t.integer :user_id
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              def self.down
         
     | 
| 
       16 
     | 
    
         
            -
            		drop_table :user_groups_users
         
     | 
| 
       17 
     | 
    
         
            -
                drop_table :user_groups
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,17 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            class CreateUsers < ActiveRecord::Migration
         
     | 
| 
       2 
     | 
    
         
            -
              def self.up
         
     | 
| 
       3 
     | 
    
         
            -
                create_table :users do |t|
         
     | 
| 
       4 
     | 
    
         
            -
                  t.string :login
         
     | 
| 
       5 
     | 
    
         
            -
                  t.string :crypted_password
         
     | 
| 
       6 
     | 
    
         
            -
                  t.string :salt
         
     | 
| 
       7 
     | 
    
         
            -
                  t.integer :profile_id
         
     | 
| 
       8 
     | 
    
         
            -
                  t.integer :updated_by
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  t.timestamps
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              def self.down
         
     | 
| 
       15 
     | 
    
         
            -
                drop_table :users
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,42 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #
         
     | 
| 
       2 
     | 
    
         
            -
            #                           !!!!IMPORTANT!!!!
         
     | 
| 
       3 
     | 
    
         
            -
            #
         
     | 
| 
       4 
     | 
    
         
            -
            #*** MUST define a current_user method that will return the current user object
         
     | 
| 
       5 
     | 
    
         
            -
            #
         
     | 
| 
       6 
     | 
    
         
            -
            #*** MUST add call to add_lockdown_session_values to your login method
         
     | 
| 
       7 
     | 
    
         
            -
            #
         
     | 
| 
       8 
     | 
    
         
            -
            #*** MAY NEED to add call to reset_lockdown_session to your logout method. 
         
     | 
| 
       9 
     | 
    
         
            -
            # ** Not needed if your authentication system resets the session
         
     | 
| 
       10 
     | 
    
         
            -
            #   
         
     | 
| 
       11 
     | 
    
         
            -
            # Definitely need to use the user_group and permission models.  The lockdown 
         
     | 
| 
       12 
     | 
    
         
            -
            # generator will provide those for you.  Just add the following to your user
         
     | 
| 
       13 
     | 
    
         
            -
            # model:
         
     | 
| 
       14 
     | 
    
         
            -
            #   has_and_belongs_to_many :user_groups
         
     | 
| 
       15 
     | 
    
         
            -
            #
         
     | 
| 
       16 
     | 
    
         
            -
            # That's it! 
         
     | 
| 
       17 
     | 
    
         
            -
            #
         
     | 
| 
       18 
     | 
    
         
            -
            #
         
     | 
| 
       19 
     | 
    
         
            -
            #                       ~~~~Method Descriptions~~~~
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            # The Lockdown gem defines these session methods:
         
     | 
| 
       22 
     | 
    
         
            -
            #
         
     | 
| 
       23 
     | 
    
         
            -
            # current_user_id: returns the id of the current_user
         
     | 
| 
       24 
     | 
    
         
            -
            #
         
     | 
| 
       25 
     | 
    
         
            -
            # logged_in? : returns true if current_user_id > 0
         
     | 
| 
       26 
     | 
    
         
            -
            #
         
     | 
| 
       27 
     | 
    
         
            -
            # current_user_is_admin?: returns true if user is assigned 
         
     | 
| 
       28 
     | 
    
         
            -
            # administrator rights.
         
     | 
| 
       29 
     | 
    
         
            -
            #
         
     | 
| 
       30 
     | 
    
         
            -
            # reset_lockdown_session: This will nil the following session values:
         
     | 
| 
       31 
     | 
    
         
            -
            #   current_user_id
         
     | 
| 
       32 
     | 
    
         
            -
            #   access_rights
         
     | 
| 
       33 
     | 
    
         
            -
            #   expiry_time
         
     | 
| 
       34 
     | 
    
         
            -
            #
         
     | 
| 
       35 
     | 
    
         
            -
            # current_user_access_in_group?(grp):  grp is a symbol referencing a 
         
     | 
| 
       36 
     | 
    
         
            -
            # Lockdown::UserGroups method such as :registered_users
         
     | 
| 
       37 
     | 
    
         
            -
            # Will return true if the session[:access_rights] contain at 
         
     | 
| 
       38 
     | 
    
         
            -
            # least one match to the access_right list associated to the group
         
     | 
| 
       39 
     | 
    
         
            -
            #
         
     | 
| 
       40 
     | 
    
         
            -
            # If you want access to any of these methods in your view, just add them 
         
     | 
| 
       41 
     | 
    
         
            -
            # as helpers in your controller (application controller for global use).
         
     | 
| 
       42 
     | 
    
         
            -
            #
         
     |