Changeset 221
- Timestamp:
- 01/12/06 03:12:36 (3 years ago)
- Files:
-
- plugins/user_engine/README (modified) (2 diffs)
- plugins/user_engine/app/controllers/user_controller.rb (modified) (1 diff)
- plugins/user_engine/app/models/role.rb (modified) (1 diff)
- plugins/user_engine/lib/user_engine.rb (modified) (1 diff)
- plugins/user_engine/tasks/user_engine.rake (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/user_engine/README
r155 r221 80 80 10. The UserEngine provides a default stylesheet and a small javascript helper file (used in the Role#edit action), so you'll probably want to include the former and almost certainly the latter in your application's layout. Add the following lines: 81 81 82 <%= engine_stylesheet "user " %>83 <%= engine_javascript "user " %>82 <%= engine_stylesheet "user_engine" %> 83 <%= engine_javascript "user_engine" %> 84 84 85 85 11. Remove any existing sessions (since they might interfere with the login process), and start the server and log using your administrator login and password (if you didn't set one explicitly in your configuration, the defaults are 'admin'/'testing' - make sure you change them!) and go to http://localhost:3000/user/list to see a list of all the users. From there you can create new users, view roles & permissions, and play around... … … 182 182 183 183 184 = Notes 185 186 === Database Schemas & Testing 187 188 Currently, since not all databases appear to support structure cloning, the tests will load the entire schema into your test database, potentially blowing away any other test structures you might have. If this presents an issue for your application, comment out the line in test/test_helper.rb 189 190 184 191 = LICENSE 185 192 plugins/user_engine/app/controllers/user_controller.rb
r153 r221 36 36 @content_columns = user_content_columns_to_display 37 37 @user_pages, @all_users = paginate :user, :per_page => 10 38 end39 40 # We need to wrap around the old edit41 alias :old_edit :edit42 def edit43 @all_roles = Role.find_all.select { |r| r.name != UserEngine.config(:guest_role_name) }44 old_edit45 38 end 46 39 plugins/user_engine/app/models/role.rb
r153 r221 38 38 # there can only be one omnipotent role. 39 39 def validate_on_create 40 if self.omnipotent? && Role.find_by_omnipotent( 1)40 if self.omnipotent? && Role.find_by_omnipotent(true) 41 41 errors.add_to_base("There can only be one omnipotent role.") 42 42 end plugins/user_engine/lib/user_engine.rb
r153 r221 152 152 # actually generating the link. 153 153 auth_options = options.dup 154 auth_options[:controller].gsub!(/^\//, '') if auth_options[:controller] 154 if auth_options[:controller] 155 auth_options[:controller] = auth_options[:controller].gsub(/^\//, '') 156 end 155 157 156 158 (block.nil? || (yield block)) && authorized?(auth_options) { plugins/user_engine/tasks/user_engine.rake
r153 r221 24 24 u.change_password UserEngine.config(:admin_password) 25 25 u.verified = 1 26 u.save26 raise "Couldn't save administrator!" if !u.save 27 27 end 28 28 … … 31 31 u.roles << Role.find_by_name(UserEngine.config(:admin_role_name)) 32 32 end 33 34 raise "Couldn't save administrator after assigning roles!" if !u.save 33 35 end 34 36 … … 43 45 guest.description = "Implicit role for all accessors of the site" 44 46 guest.system_role = true 47 guest.omnipotent = false 48 raise "Couldn't save guest role!" if !guest.save 45 49 46 50 guest.permissions << Permission.find_by_controller_and_action('user', 'login') … … 48 52 guest.permissions << Permission.find_by_controller_and_action('user', 'signup') 49 53 50 guest.save54 raise "Couldn't save guest role after setting permissions!" if !guest.save 51 55 end 52 56 … … 61 65 admin.omnipotent = true 62 66 admin.system_role = true 67 raise "Couldn't save admin role!" if !admin.save 63 68 64 69 @all_action_permissions.each { |permission| … … 68 73 } 69 74 70 admin.save75 raise "Couldn't save admin role after assigning permissions!" if !admin.save 71 76 end 72 77 … … 78 83 user.description = "The default role for all logged-in users" 79 84 user.system_role = true 85 user.omnipotent = false 86 raise "Couldn't save default user role!" if !user.save 80 87 81 88 # all users automatically get the Guest permissions implicitly … … 85 92 user.permissions << Permission.find_by_controller_and_action('user', 'edit') 86 93 87 user.save94 raise "Couldn't save default user role after assigning permissions!" if !user.save 88 95 end 89 96 end
