Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added auth module

  • Loading branch information...
commit 2cb3c73ed2291f748f6ed1f2d30cc3e2d23d6bf8 1 parent bf26a8c
@lackac authored
Showing with 33 additions and 0 deletions.
  1. +2 −0  README.md
  2. +1 −0  app_lego.rb
  3. +30 −0 auth.rb
View
2  README.md
@@ -36,6 +36,8 @@ The **Haml** module initializes the app for [Haml](http://haml.hamptoncatlin.com
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](http://github.com/jchris/couchrest/tree/master) gem and the [BasicModel](http://github.com/topfunky/basic_model/tree/master) plugin.
The **locale** module will download localization files from Sven Fuchs' [rails-i18n](http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) 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:
View
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 + Script.aculo.us?"],
+ ["auth", "Add authentication module?"],
["couchdb", "Use CouchDB?"],
["locale", "Add specific localizations?"],
["misc", "Add miscellaneous stuff (helpers, basic layout, flashes, initializers)?"],
View
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
+end
+ RB
+
+ log "NOTE", "Don't forget to run 'rake db:migrate'."
+end
+
+git :add => "."
+git :commit => "-a -m 'Added AuthLogic#{" and #{user_model} model" unless user_model.blank?}'"
Please sign in to comment.
Something went wrong with that request. Please try again.