challah 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Challah 0.7.1
2
+
3
+ * Ensure users can be looked up by username as case insensitive value. Allows logins posted from iOS devices (with initial caps) to be valid usernames even when stored as caps.
4
+
1
5
  ## Challah 0.7.0
2
6
 
3
7
  * Removed roles and permissions functionality to keep the gem completely geared towards user authentication. In a future release this functionality will be added back into its own separate gem.
data/lib/challah/user.rb CHANGED
@@ -69,7 +69,7 @@ module Challah
69
69
 
70
70
  result = nil
71
71
 
72
- result = self.where(:username => username_or_email).first
72
+ result = self.where(:username => username_or_email.to_s.strip.downcase).first
73
73
 
74
74
  unless result
75
75
  if username_or_email.to_s.include?('@')
@@ -230,6 +230,9 @@ module Challah
230
230
  if self.username.to_s.blank? and !self.email.to_s.blank?
231
231
  self.username = self.email
232
232
  end
233
+
234
+ # Make sure username stored is always stripped of whitespace and downcased
235
+ self.username = self.username.to_s.strip.downcase
233
236
  end
234
237
 
235
238
  # validation call for new passwords, make sure the password is confirmed, and is >= 4 characters
@@ -1,3 +1,3 @@
1
1
  module Challah
2
- VERSION = "0.7.0" unless defined?(::Challah::VERSION)
2
+ VERSION = "0.7.1" unless defined?(::Challah::VERSION)
3
3
  end
data/test/user_test.rb CHANGED
@@ -17,12 +17,15 @@ class UserTest < ActiveSupport::TestCase
17
17
 
18
18
  context "A User class" do
19
19
  should "find a user by username or email" do
20
- user_one = create(:user, :username => 'test-user', :email => 'tester@example.com')
21
- user_two = create(:user, :username => 'test-user-2', :email => 'tester2@example.com')
20
+ user_one = create(:user, :username => ' Test-user ', :email => 'tester@example.com')
21
+ user_two = create(:user, :username => 'test-user-2 ', :email => 'tester2@example.com')
22
22
 
23
23
  assert_equal user_one, ::User.find_for_session('test-user')
24
24
  assert_equal user_one, ::User.find_for_session('tester@example.com')
25
25
 
26
+ assert_equal user_one, ::User.find_for_session('Test-user')
27
+ assert_equal user_one, ::User.find_for_session('tester@example.com')
28
+
26
29
  assert_equal user_two, ::User.find_for_session('test-user-2')
27
30
  assert_equal user_two, ::User.find_for_session('tester2@example.com')
28
31
 
@@ -132,6 +135,13 @@ class UserTest < ActiveSupport::TestCase
132
135
  assert user.errors.full_messages.include?("Password does not match the confirmation password.")
133
136
  end
134
137
 
138
+ should "always lower case a username when setting" do
139
+ user = build(:user)
140
+ user.username = 'JimBob'
141
+ assert user.save
142
+ assert_equal 'jimbob', user.username
143
+ end
144
+
135
145
  should "authenticate through various means by default" do
136
146
  user = create(:user)
137
147
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: challah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
16
- requirement: &70126733377560 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70126733377560
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rails
27
- requirement: &70126733376880 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '3.1'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70126733376880
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.1'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &70126733376160 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.9.2
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70126733376160
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bcrypt-ruby
49
- requirement: &70126733375400 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70126733375400
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: A simple Rails engine gem for authentication, authorization, users, roles
59
79
  and permissions.
60
80
  email:
@@ -5185,7 +5205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
5185
5205
  version: '0'
5186
5206
  requirements: []
5187
5207
  rubyforge_project:
5188
- rubygems_version: 1.8.15
5208
+ rubygems_version: 1.8.23
5189
5209
  signing_key:
5190
5210
  specification_version: 3
5191
5211
  summary: Simple authentication and authorization gem for Rails.