wheels 0.0.43 → 0.0.44

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.43
1
+ 0.0.44
@@ -14,20 +14,15 @@ class UsersController < InheritedResources::Base
14
14
  end
15
15
 
16
16
  def verify
17
- respond_with @user do |format|
18
- format.json {render :json=> @user.valid_password?(params[:password]).to_json}
17
+ respond_with resource do |format|
18
+ format.json {render :json=> resource.valid_password?(params[:password]).to_json}
19
19
  end
20
20
  end
21
21
 
22
22
  def resource
23
23
  @user ||= lambda{
24
24
  user = User.find(current_user)
25
- user.class_eval do
26
- attr_accessor :old_password
27
- validates :old_password, :presence=>true , :password=>true
28
- validates :password, :presence=>true , :length=>{:minimum=>6}
29
- validates :password_confirmation, :equal_to=>{:other=>:password}
30
- end
25
+ user.extend(PasswordValidators)
31
26
  user
32
27
  }.call
33
28
  end
data/app/models/user.rb CHANGED
@@ -8,6 +8,15 @@ class User < ActiveRecord::Base
8
8
 
9
9
  validates :email, :presence => true
10
10
 
11
+ def validates_password
12
+ class_eval do
13
+ attr_accessor :old_password
14
+ validates :old_password, :presence=>true , :password=>true
15
+ validates :password, :presence=>true , :length=>{:minimum=>6}
16
+ validates :password_confirmation, :equal_to=>{:other=>:password}
17
+ end
18
+ end
19
+
11
20
  def self.nobody
12
21
  User.new(:role=>Role.nobody)
13
22
  end
@@ -0,0 +1,9 @@
1
+ module PasswordValidators
2
+ def self.extended(base)
3
+ attr_accessor :old_password
4
+ validates :old_password, :presence=>true , :password=>true
5
+ validates :password, :presence=>true , :length=>{:minimum=>6}
6
+ validates :password_confirmation, :equal_to=>{:other=>:password}
7
+ end
8
+ end
9
+
data/lib/wheels.rb CHANGED
@@ -4,5 +4,6 @@ require 'wheels/action_controller_extensions.rb'
4
4
  require 'wheels/action_view_helper_extensions.rb'
5
5
  require 'wheels/flash_session_cookie_middleware.rb'
6
6
  require 'wheels/paperclip_interpolations.rb'
7
+ require 'wheels/password_validators.rb'
7
8
  # require 'wheels/s3login_provider.rb'
8
9
 
data/wheels.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wheels}
8
- s.version = "0.0.43"
8
+ s.version = "0.0.44"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyler Gannon"]
@@ -214,6 +214,7 @@ Gem::Specification.new do |s|
214
214
  "lib/wheels/active_record_user_extensions.rb",
215
215
  "lib/wheels/flash_session_cookie_middleware.rb",
216
216
  "lib/wheels/paperclip_interpolations.rb",
217
+ "lib/wheels/password_validators.rb",
217
218
  "lib/wheels/routes.rb",
218
219
  "lib/wheels/s3login_provider.rb",
219
220
  "lib/wheels/user.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 43
9
- version: 0.0.43
8
+ - 44
9
+ version: 0.0.44
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tyler Gannon
@@ -237,6 +237,7 @@ files:
237
237
  - lib/wheels/active_record_user_extensions.rb
238
238
  - lib/wheels/flash_session_cookie_middleware.rb
239
239
  - lib/wheels/paperclip_interpolations.rb
240
+ - lib/wheels/password_validators.rb
240
241
  - lib/wheels/routes.rb
241
242
  - lib/wheels/s3login_provider.rb
242
243
  - lib/wheels/user.rb