forked from lackac/app_lego
-
Notifications
You must be signed in to change notification settings - Fork 1
/
auth.rb
39 lines (27 loc) · 1.42 KB
/
auth.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This installs Authlogic stuff at the moment but could support others too
gem 'authlogic'
rake "gems:install", :sudo=>true
generate 'session', 'user_session'
file 'test/test_helper.rb', <<-TEST
# test/test_helper.rb
require 'authlogic/testing/test_unit_helpers'
TEST
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 failed_login_count:integer last_request_at:datetime"
#for acts_as_authenticated "login_count:integer failed_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
rake "db:migrate"
end
git :add => "."
git :commit => "-a -m 'Added AuthLogic#{" and #{user_model} model" unless user_model.blank?}'"