ateam-merb-auth-old 0.0.1

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.
Files changed (69) hide show
  1. data/LICENSE +44 -0
  2. data/README +212 -0
  3. data/Rakefile +50 -0
  4. data/TODO +14 -0
  5. data/activerecord_generators/ma_migration/ma_migration_generator.rb +41 -0
  6. data/activerecord_generators/ma_migration/templates/schema/migrations/%time_stamp%_add_ma_user.rb +21 -0
  7. data/app/controllers/application.rb +7 -0
  8. data/app/controllers/sessions.rb +3 -0
  9. data/app/controllers/users.rb +3 -0
  10. data/app/helpers/application_helper.rb +64 -0
  11. data/app/mailers/user_mailer.rb +24 -0
  12. data/app/mailers/views/user_mailer/activation.text.erb +1 -0
  13. data/app/mailers/views/user_mailer/forgot_password.text.erb +5 -0
  14. data/app/mailers/views/user_mailer/signup.text.erb +7 -0
  15. data/app/views/layout/merb_auth.html.erb +16 -0
  16. data/app/views/sessions/new.html.erb +13 -0
  17. data/app/views/users/new.html.erb +21 -0
  18. data/datamapper_generators/ma_migration/ma_migration_generator.rb +38 -0
  19. data/datamapper_generators/ma_migration/templates/schema/migrations/add_ma_user.rb +21 -0
  20. data/lib/ateam-merb-auth-old.rb +1 -0
  21. data/lib/merb-auth.rb +184 -0
  22. data/lib/merb-auth/adapters/activerecord/init.rb +26 -0
  23. data/lib/merb-auth/adapters/activerecord/map.rb +44 -0
  24. data/lib/merb-auth/adapters/activerecord/model.rb +81 -0
  25. data/lib/merb-auth/adapters/common.rb +161 -0
  26. data/lib/merb-auth/adapters/datamapper/init.rb +28 -0
  27. data/lib/merb-auth/adapters/datamapper/map.rb +35 -0
  28. data/lib/merb-auth/adapters/datamapper/model.rb +72 -0
  29. data/lib/merb-auth/adapters/map.rb +0 -0
  30. data/lib/merb-auth/adapters/sequel/init.rb +26 -0
  31. data/lib/merb-auth/adapters/sequel/map.rb +36 -0
  32. data/lib/merb-auth/adapters/sequel/model.rb +86 -0
  33. data/lib/merb-auth/controller/controller.rb +113 -0
  34. data/lib/merb-auth/controller/sessions_base.rb +41 -0
  35. data/lib/merb-auth/controller/users_base.rb +58 -0
  36. data/lib/merb-auth/initializer.rb +47 -0
  37. data/lib/merb-auth/merbtasks.rb +168 -0
  38. data/lib/merb-auth/slicetasks.rb +102 -0
  39. data/plugins/forgotten_password/app/controllers/passwords.rb +90 -0
  40. data/plugins/forgotten_password/app/models/user.rb +52 -0
  41. data/plugins/forgotten_password/app/views/passwords/edit.html.erb +9 -0
  42. data/plugins/forgotten_password/app/views/passwords/new.html.erb +4 -0
  43. data/plugins/forgotten_password/forgotten_password.rb +6 -0
  44. data/plugins/forgotten_password/init.rb +8 -0
  45. data/plugins/forgotten_password/spec/controller_spec.rb +236 -0
  46. data/plugins/forgotten_password/spec/model_spec.rb +52 -0
  47. data/plugins/forgotten_password/spec/spec_helper.rb +36 -0
  48. data/public/javascripts/master.js +0 -0
  49. data/public/stylesheets/master.css +2 -0
  50. data/spec/controllers/plugins/test_plugin.rb +17 -0
  51. data/spec/controllers/sessions_spec.rb +118 -0
  52. data/spec/controllers/users_spec.rb +119 -0
  53. data/spec/mailers/user_mailer_spec.rb +75 -0
  54. data/spec/merb_auth_spec.rb +231 -0
  55. data/spec/models/ar_model_spec.rb +50 -0
  56. data/spec/models/common_spec.rb +0 -0
  57. data/spec/models/model_spec.rb +23 -0
  58. data/spec/models/sq_model_spec.rb +50 -0
  59. data/spec/shared_specs/shared_model_spec.rb +445 -0
  60. data/spec/spec_helper.rb +114 -0
  61. data/spec/spec_helpers/helpers.rb +18 -0
  62. data/spec/spec_helpers/valid_model_hashes.rb +10 -0
  63. data/stubs/app/controllers/application.rb +2 -0
  64. data/stubs/app/controllers/main.rb +2 -0
  65. data/stubs/app/mailers/views/activation.text.erb +1 -0
  66. data/stubs/app/mailers/views/signup.text.erb +7 -0
  67. data/stubs/app/views/sessions/new.html.erb +14 -0
  68. data/stubs/app/views/users/new.html.erb +18 -0
  69. metadata +120 -0
@@ -0,0 +1,113 @@
1
+ module MerbAuth
2
+ module Controller
3
+ module Helpers
4
+ protected
5
+ # Returns true or false if the user is logged in.
6
+ # Preloads @current_ma_user with the user model if they're logged in.
7
+ def logged_in?
8
+ !!current_ma_user
9
+ end
10
+
11
+ # Accesses the current user from the session. Set it to :false if login fails
12
+ # so that future calls do not hit the database.
13
+ def current_ma_user
14
+ @current_ma_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || false)
15
+ end
16
+
17
+ # Store the given user in the session.
18
+ def current_ma_user=(new_user)
19
+ session[MA[:single_resource]] = (!new_user || !new_user.kind_of?(MA[:user])) ? nil : new_user.id
20
+ @current_ma_user = new_user
21
+ end
22
+
23
+ # Check if the user is authorized
24
+ #
25
+ # Override this method in your controllers if you want to restrict access
26
+ # to only a few actions or if you want to check if the user
27
+ # has the correct rights.
28
+ #
29
+ # Example:
30
+ #
31
+ # # only allow nonbobs
32
+ # def authorized?
33
+ # current_ma_user.login != "bob"
34
+ # end
35
+ def authorized?
36
+ logged_in?
37
+ end
38
+
39
+ # Filter method to enforce a login requirement.
40
+ #
41
+ # To require logins for all actions, use this in your controllers:
42
+ #
43
+ # before_filter :login_required
44
+ #
45
+ # To require logins for specific actions, use this in your controllers:
46
+ #
47
+ # before_filter :login_required, :only => [ :edit, :update ]
48
+ #
49
+ # To skip this in a subclassed controller:
50
+ #
51
+ # skip_before_filter :login_required
52
+ #
53
+ def login_required
54
+ authorized? || throw(:halt, :access_denied)
55
+ end
56
+
57
+ # Redirect as appropriate when an access request fails.
58
+ #
59
+ # The default action is to redirect to the login screen.
60
+ #
61
+ # Override this method in your controllers if you want to have special
62
+ # behavior in case the user is not authorized
63
+ # to access the requested action. For example, a popup window might
64
+ # simply close itself.
65
+ def access_denied
66
+ case content_type
67
+ when :html
68
+ store_location
69
+ redirect url(:merb_auth_login)
70
+ when :xml
71
+ basic_authentication.request
72
+ end
73
+ end
74
+
75
+ # Store the URI of the current request in the session.
76
+ #
77
+ # We can return to this location by calling #redirect_back_or_default.
78
+ def store_location
79
+ session[:return_to] = request.uri
80
+ end
81
+
82
+ # Redirect to the URI stored by the most recent store_location call or
83
+ # to the passed default.
84
+ def redirect_back_or_default(default, notice = "")
85
+ url = session[:return_to] || default
86
+ session[:return_to] = nil
87
+ redirect url, :notice => notice
88
+ end
89
+
90
+ # Called from #current_ma_user. First attempt to login by the user id stored in the session.
91
+ def login_from_session
92
+ self.current_ma_user = MA[:user].find_with_conditions(:id => session[MA[:single_resource]]) if session[MA[:single_resource]]
93
+ end
94
+
95
+ # Called from #current_ma_user. Now, attempt to login by basic authentication information.
96
+ def login_from_basic_auth
97
+ basic_authentication.authenticate do |email, password|
98
+ self.current_ma_user = MA[:user].authenticate(email, password)
99
+ end
100
+ end
101
+
102
+ # Called from #current_ma_user. Finaly, attempt to login by an expiring token in the cookie.
103
+ def login_from_cookie
104
+ user = cookies[:auth_token] && MA[:user].find_with_conditions(:remember_token => cookies[:auth_token])
105
+ if user && user.remember_token?
106
+ user.remember_me
107
+ cookies[:auth_token] = { :value => user.remember_token, :expires => Time.parse(user.remember_token_expires_at.to_s) }
108
+ self.current_ma_user = user
109
+ end
110
+ end
111
+ end # Helpers
112
+ end# Controllers
113
+ end # MerbAuth
@@ -0,0 +1,41 @@
1
+ module MerbAuth
2
+ module Controller
3
+ # Provides basic functionality for sessions. eg Allows login and logout.
4
+ module SessionsBase
5
+
6
+ def self.included(base)
7
+ # base.send(:skip_before, :login_required)
8
+ base.send(:include, InstanceMethods)
9
+ base.send(:show_action, :new, :create, :destroy)
10
+ end
11
+
12
+ module InstanceMethods
13
+ def new
14
+ render
15
+ end
16
+
17
+ def create
18
+ self.current_ma_user = MA[:user].authenticate(params[MA[:login_field]], params[:password])
19
+ if logged_in?
20
+ if params[:remember_me] == "1"
21
+ self.current_ma_user.remember_me
22
+ expires = Time.parse(self.current_ma_user.remember_token_expires_at.to_s)
23
+ cookies[:auth_token] = { :value => self.current_ma_user.remember_token , :expires => expires }
24
+ end
25
+ redirect_back_or_default('/')
26
+ else
27
+ render :new
28
+ end
29
+ end
30
+
31
+ def destroy
32
+ self.current_ma_user.forget_me if logged_in?
33
+ cookies.delete :auth_token
34
+ session.clear
35
+ redirect_back_or_default('/')
36
+ end
37
+ end # InstanceMethods
38
+
39
+ end # SessionsBase
40
+ end # Controller
41
+ end # MerbAuth
@@ -0,0 +1,58 @@
1
+ module MerbAuth
2
+ module Controller
3
+
4
+ # Provides basic functionality for the users controller. Allows creation of a new user and activation
5
+ module UsersBase
6
+
7
+ def self.included(base)
8
+ # base.send(:skip_before, :login_required)
9
+ base.send(:include, InstanceMethods)
10
+ base.send(:show_action, :new, :create, :activate)
11
+ end
12
+
13
+ module InstanceMethods
14
+ # Displays the new form for the user
15
+ def new
16
+ only_provides :html
17
+ @ivar = MA[:user].new(params[MA[:single_resource]] || {})
18
+ set_ivar
19
+ display @ivar
20
+ end
21
+
22
+ def create
23
+ cookies.delete :auth_token
24
+ @use_recaptcha = Object.const_defined?(:Ambethia)
25
+
26
+ @ivar = MA[:user].new(params[MA[:single_resource]])
27
+ set_ivar
28
+ #if (!@use_recaptcha || verify_recaptcha(@ivar, :failure_message => nil)) && @ivar.save
29
+ if (!@use_recaptcha || verify_recaptcha(@ivar, :failure_message => nil)) && @ivar.valid?
30
+ @ivar.save
31
+ self.current_ma_user = @ivar unless MA[:use_activation]
32
+ redirect_back_or_default('/')
33
+
34
+ else
35
+ render :new
36
+ end
37
+ end
38
+
39
+ def activate
40
+ self.current_ma_user = MA[:user].find_with_conditions(:activation_code => params[:activation_code])
41
+ if logged_in? && !current_ma_user.activated?
42
+ Merb.logger.info "Activated #{current_ma_user}"
43
+ current_ma_user.activate
44
+ end
45
+ redirect_back_or_default('/')
46
+ end
47
+
48
+ private
49
+ # sets the instance variable for the developer to use eg. @user
50
+ def set_ivar
51
+ instance_variable_set("@#{MA[:single_resource]}", @ivar)
52
+ end
53
+
54
+ end # InstanceMethods
55
+
56
+ end # UsersBase
57
+ end # Controllers
58
+ end #MerbAuth
@@ -0,0 +1,47 @@
1
+ module MerbAuth
2
+
3
+ # Clears the currently registered adapter list.
4
+ def self.clear_adapter_list!
5
+ @_adapters = nil
6
+ end
7
+
8
+ # Registers an adapter.
9
+ # @param [Symbol] name is the name of the adapter. Supported adapters are :datamapper and :activerecord
10
+ # @param [String] path is the path to the adapter. The adapter path _directory_ should include an init.rb file
11
+ # @param [Hash] opts an options hash
12
+ def self.register_adapter(name, path, opts = {})
13
+ adapters[name.to_sym] = opts.merge!(:path => path)
14
+ end
15
+
16
+ # @return [Hash] A hash of the adapters.
17
+ def self.adapters
18
+ @_adapters ||= Hash.new{|h,k| h[k] = {}}
19
+ end
20
+
21
+
22
+ # Loads the adapter provided, or if not provided, the adapter set in the slices config
23
+ # @param [Symbol | String] adapter The name of the adapter to load. This must be registered
24
+ # @raise [RuntimeError] Raises an error if the adapter is not registered.
25
+ def self.load_adapter!(adapter = nil)
26
+ adapter ||= self.config[:adapter] || Merb.orm_generator_scope
27
+ raise "MerbAuth: No Adapter Specified" if adapter.nil? || adapter.blank?
28
+
29
+ # Check that the adapter is registered
30
+ raise "MerbAuth: Adapter Not Registered - #{adapter}" unless adapters.keys.include?(adapter.to_sym)
31
+
32
+ if Merb.env?(:test)
33
+ load adapters[adapter.to_sym][:path] / "init.rb"
34
+ else
35
+ require adapters[adapter.to_sym][:path] / "init"
36
+ end
37
+ end
38
+
39
+ def self.load_plugins!
40
+ self.plugins.each do |label, file|
41
+ Merb.logger.info "Loading MerbAuth Plugin - #{label}"
42
+ load file
43
+ end
44
+ MA.setup_custom_routes!
45
+ end
46
+
47
+ end
@@ -0,0 +1,168 @@
1
+ $SLICED_APP=true # we're running inside the host application context
2
+
3
+ namespace :slices do
4
+ namespace :merb_auth do
5
+
6
+ desc "Install MerbAuth"
7
+ task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
8
+
9
+ desc "Test for any dependencies"
10
+ task :preflight do # see slicetasks.rb
11
+ end
12
+
13
+ desc "Setup directories"
14
+ task :setup_directories do
15
+ puts "Creating directories for host application"
16
+ MerbAuth.mirrored_components.each do |type|
17
+ if File.directory?(MerbAuth.dir_for(type))
18
+ if !File.directory?(dst_path = MerbAuth.app_dir_for(type))
19
+ relative_path = dst_path.relative_path_from(Merb.root)
20
+ puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
21
+ mkdir_p(dst_path)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ desc "Copy stub files to host application"
28
+ task :stubs do
29
+ puts "Copying stubs for MerbAuth - resolves any collisions"
30
+ copied, preserved = MerbAuth.mirror_stubs!
31
+ puts "- no files to copy" if copied.empty? && preserved.empty?
32
+ copied.each { |f| puts "- copied #{f}" }
33
+ preserved.each { |f| puts "! preserved override as #{f}" }
34
+ end
35
+
36
+ desc "Copy stub files and views to host application"
37
+ task :patch => [ "stubs", "freeze:views" ]
38
+
39
+ desc "Copy public assets to host application"
40
+ task :copy_assets do
41
+ puts "Copying assets for MerbAuth - resolves any collisions"
42
+ copied, preserved = MerbAuth.mirror_public!
43
+ puts "- no files to copy" if copied.empty? && preserved.empty?
44
+ copied.each { |f| puts "- copied #{f}" }
45
+ preserved.each { |f| puts "! preserved override as #{f}" }
46
+ end
47
+
48
+ desc "Migrate the database"
49
+ task :migrate do # see slicetasks.rb
50
+ end
51
+
52
+ desc "Freeze MerbAuth into your app (only merb-auth/app)"
53
+ task :freeze => [ "freeze:app" ]
54
+
55
+ namespace :freeze do
56
+
57
+ desc "Freezes MerbAuth by installing the gem into application/gems using merb-freezer"
58
+ task :gem do
59
+ begin
60
+ Object.const_get(:Freezer).freeze(ENV["GEM"] || "merb-auth", ENV["UPDATE"], ENV["MODE"] || 'rubygems')
61
+ rescue NameError
62
+ puts "! dependency 'merb-freezer' missing"
63
+ end
64
+ end
65
+
66
+ desc "Freezes MerbAuth by copying all files from merb-auth/app to your application"
67
+ task :app do
68
+ puts "Copying all merb-auth/app files to your application - resolves any collisions"
69
+ copied, preserved = MerbAuth.mirror_app!
70
+ puts "- no files to copy" if copied.empty? && preserved.empty?
71
+ copied.each { |f| puts "- copied #{f}" }
72
+ preserved.each { |f| puts "! preserved override as #{f}" }
73
+ end
74
+
75
+ desc "Freeze all views into your application for easy modification"
76
+ task :views do
77
+ puts "Copying all view templates to your application - resolves any collisions"
78
+ copied, preserved = MerbAuth.mirror_files_for :view
79
+ puts "- no files to copy" if copied.empty? && preserved.empty?
80
+ copied.each { |f| puts "- copied #{f}" }
81
+ preserved.each { |f| puts "! preserved override as #{f}" }
82
+ end
83
+
84
+ desc "Freeze all models into your application for easy modification"
85
+ task :models do
86
+ puts "Copying all models to your application - resolves any collisions"
87
+ copied, preserved = MerbAuth.mirror_files_for :model
88
+ puts "- no files to copy" if copied.empty? && preserved.empty?
89
+ copied.each { |f| puts "- copied #{f}" }
90
+ preserved.each { |f| puts "! preserved override as #{f}" }
91
+ end
92
+
93
+ desc "Freezes MerbAuth as a gem and copies over merb-auth/app"
94
+ task :app_with_gem => [:gem, :app]
95
+
96
+ desc "Freezes MerbAuth by unpacking all files into your application"
97
+ task :unpack do
98
+ puts "Unpacking MerbAuth files to your application - resolves any collisions"
99
+ copied, preserved = MerbAuth.unpack_slice!
100
+ puts "- no files to copy" if copied.empty? && preserved.empty?
101
+ copied.each { |f| puts "- copied #{f}" }
102
+ preserved.each { |f| puts "! preserved override as #{f}" }
103
+ end
104
+
105
+ end
106
+
107
+ desc "Run slice specs within the host application context"
108
+ task :spec => [ "spec:explain", "spec:default" ]
109
+
110
+ namespace :spec do
111
+
112
+ slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
113
+
114
+ task :explain do
115
+ puts "\nNote: By running MerbAuth specs inside the application context any\n" +
116
+ "overrides could break existing specs. This isn't always a problem,\n" +
117
+ "especially in the case of views. Use these spec tasks to check how\n" +
118
+ "well your application conforms to the original slice implementation."
119
+ end
120
+
121
+ Spec::Rake::SpecTask.new('default') do |t|
122
+ t.spec_opts = ["--format", "specdoc", "--colour"]
123
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
124
+ end
125
+
126
+ desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
127
+ Spec::Rake::SpecTask.new('model') do |t|
128
+ t.spec_opts = ["--format", "specdoc", "--colour"]
129
+ if(ENV['MODEL'])
130
+ t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
131
+ else
132
+ t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
133
+ end
134
+ end
135
+
136
+ desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
137
+ Spec::Rake::SpecTask.new('controller') do |t|
138
+ t.spec_opts = ["--format", "specdoc", "--colour"]
139
+ if(ENV['CONTROLLER'])
140
+ t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
141
+ else
142
+ t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
143
+ end
144
+ end
145
+
146
+ desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
147
+ Spec::Rake::SpecTask.new('view') do |t|
148
+ t.spec_opts = ["--format", "specdoc", "--colour"]
149
+ if(ENV['CONTROLLER'] and ENV['VIEW'])
150
+ t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
151
+ elsif(ENV['CONTROLLER'])
152
+ t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
153
+ else
154
+ t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
155
+ end
156
+ end
157
+
158
+ desc "Run all specs and output the result in html"
159
+ Spec::Rake::SpecTask.new('html') do |t|
160
+ t.spec_opts = ["--format", "html"]
161
+ t.libs = ['lib', 'server/lib' ]
162
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
163
+ end
164
+
165
+ end
166
+
167
+ end
168
+ end
@@ -0,0 +1,102 @@
1
+ namespace :slices do
2
+ namespace :merb_auth do
3
+
4
+ # add your own merb_auth tasks here
5
+
6
+ # implement this to test for structural/code dependencies
7
+ # like certain directories or availability of other files
8
+ desc "Test for any dependencies"
9
+ task :preflight do
10
+ end
11
+
12
+ # implement this to perform any database related setup steps
13
+ desc "Migrate the database"
14
+ task :migrate do
15
+ end
16
+
17
+ desc "Generate Migration"
18
+ task :generate_migration => :merb_env do
19
+ puts `merb-gen ma_migration #{MA[:user].name}`
20
+ end
21
+
22
+ namespace :ar do
23
+ desc "Print Model Properties"
24
+ task :model_setup do
25
+ out =<<-EOS
26
+
27
+ # -------------------------------------------------------------------
28
+ include MerbAuth::Adapter::ActiveRecord
29
+
30
+ # Virtual attribute for the unencrypted password
31
+ attr_accessor :password, :password_confirmation
32
+ validates_presence_of :login, :email
33
+ validates_presence_of :password, :if => :password_required?
34
+ validates_presence_of :password_confirmation, :if => :password_required?
35
+ validates_length_of :password, :within => 4..40, :if => :password_required?
36
+ validates_confirmation_of :password, :if => :password_required?
37
+ validates_length_of :login, :within => 3..40
38
+ validates_length_of :email, :within => 3..100
39
+ validates_uniqueness_of :login, :email, :case_sensitive => false
40
+ validates_uniqueness_of :password_reset_key, :if => Proc.new{|m| !m.password_reset_key.nil?}
41
+
42
+
43
+ before_save :encrypt_password
44
+ before_validation :set_login
45
+ before_create :make_activation_code
46
+ after_create :send_signup_notification
47
+ # -------------------------------------------------------------------
48
+ EOS
49
+ puts "Enter this into your model to make it usable with MerbAuth by default"
50
+ puts out
51
+ puts "Enter this into your model to make it usable with MerbAuth by default"
52
+ end
53
+
54
+ end # ar
55
+
56
+ namespace :dm do
57
+ desc "Print Model Properties"
58
+ task :model_setup do
59
+ out =<<-EOS
60
+
61
+ # -------------------------------------------------------------------
62
+
63
+ include MerbAuth::Adapter::DataMapper
64
+
65
+ attr_accessor :password, :password_confirmation
66
+
67
+ property :id, Integer, :serial => true
68
+ property :login, String, :nullable => false, :length => 3..40, :unique => true
69
+ property :email, String, :nullable => false, :unique => true
70
+ property :created_at, DateTime
71
+ property :updated_at, DateTime
72
+ property :activated_at, DateTime
73
+ property :activation_code, String
74
+ property :crypted_password, String
75
+ property :salt, String
76
+ property :remember_token_expires_at, DateTime
77
+ property :remember_token, String
78
+ property :password_reset_key, String, :writer => :protected
79
+
80
+ validates_is_unique :password_reset_key, :if => Proc.new{|m| !m.password_reset_key.nil?}
81
+ validates_present :password, :if => proc{|m| m.password_required?}
82
+ validates_is_confirmed :password, :if => proc{|m| m.password_required?}
83
+
84
+ before :valid? do
85
+ set_login
86
+ end
87
+
88
+ before :save, :encrypt_password
89
+ before :create, :make_activation_code
90
+ after :create, :send_signup_notification
91
+
92
+ # -------------------------------------------------------------------
93
+ EOS
94
+ puts "Enter this into your model to make it usable with MerbAuth by default"
95
+ puts out
96
+ puts "Enter this into your model to make it usable with MerbAuth by default"
97
+
98
+ end # setup
99
+ end # dm
100
+
101
+ end # merb_auth
102
+ end # slices