Browse files

Added auth module

  • Loading branch information...
1 parent bf26a8c commit 2cb3c73ed2291f748f6ed1f2d30cc3e2d23d6bf8 @lackac lackac committed Feb 6, 2009
Showing with 33 additions and 0 deletions.
  1. +2 −0
  2. +1 −0 app_lego.rb
  3. +30 −0 auth.rb
@@ -36,6 +36,8 @@ The **Haml** module initializes the app for [Haml](
The **jQuery** module removes the default javascript files and installes jQuery, jQuery-UI and the jQuery Form plugin. The first two come with minified and full versions too.
+The **Auth** module adds the AuthLogic gem and generates a UserSession model for it with an optional user model. The name of the user model and the user identifier can be given in the `USER_MODEL` and `USER_IDENT` environment variables.
The **CouchDB** module installs the [CouchRest]( gem and the [BasicModel]( plugin.
The **locale** module will download localization files from Sven Fuchs' [rails-i18n]( repository. The generator will ask for the list of the localizations the user wants, but it can be given through the `LOCALES` environment variable too. The list is comma separated, and where no extension is given `.yml` is assumed. The first locale in the list will be used as the default locale. Example:
1 app_lego.rb
@@ -33,6 +33,7 @@ def plugin(name, options)
["rspec", "Use RSpec instead of test/unit?"],
["haml", "Use haml for views and sass for css?"],
["jquery", "Use jQuery instead of Prototype +"],
+ ["auth", "Add authentication module?"],
["couchdb", "Use CouchDB?"],
["locale", "Add specific localizations?"],
["misc", "Add miscellaneous stuff (helpers, basic layout, flashes, initializers)?"],
30 auth.rb
@@ -0,0 +1,30 @@
+# This installs Authlogic stuff at the moment but could support others too
+gem 'authlogic'
+generate 'session', 'user_session'
+user_model = ENV['USER_MODEL'] || ask("What should be the name of the user model? (leave it empty to skip)")
+unless user_model.blank?
+ user_ident = ENV['USER_IDENT'] || ask("What is the identifier of a user? (e.g. login, email)")
+ migration = "#{user_ident}:string crypted_password:string password_salt:string persistence_token:string single_access_token:string perishable_token:string login_count:integer last_request_at:datetime current_login_at:datetime last_login_at:datetime current_login_ip:string last_login_ip:string"
+ if File.exists?('vendor/plugins/rspec')
+ generate 'rspec_model', user_model, migration
+ else
+ generate 'model', user_model, migration
+ end
+ file "app/models/#{user_model.underscore}.rb", <<-RB
+class #{user_model.classify} < ActiveRecord::Base
+ acts_as_authentic # for options see documentation: Authlogic::ORMAdapters::ActiveRecordAdapter::ActsAsAuthentic::Config
+ RB
+ log "NOTE", "Don't forget to run 'rake db:migrate'."
+git :add => "."
+git :commit => "-a -m 'Added AuthLogic#{" and #{user_model} model" unless user_model.blank?}'"

0 comments on commit 2cb3c73

Please sign in to comment.