simple_token_authentication 1.10.1 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc9c3c84827bba7367ebae956b4570eeb08c121c
4
- data.tar.gz: 59f9d3ef5ebdd6293a72d5fe1d0032a3154b1ece
3
+ metadata.gz: 545e7e240740cd272bcb2a7be4dbd76caf150f53
4
+ data.tar.gz: cd43f4c512387a046aa9d289c94fa71b407b662e
5
5
  SHA512:
6
- metadata.gz: 80c26958d4e2bea406c1d383aa4d1bdc3272f8bb51b988130927bc8a8b1853279ccb92757a0956b491e85cdbfdd4771f78d6331c8b097f949b31cf6894cc9249
7
- data.tar.gz: acb6c207ac94633f6ee5df3355768cd153c012566d8045af01bc4d1a9d7ad625d33208d926c04b279320834988cd7948730fdce07ce760cdfb56fa2a832c5e0b
6
+ metadata.gz: bd62a1b560a22a3df914fad7277f7bed251fad0a8ae897b6606dd860b1ea6043f3a5eb509df7ed564463907a44b9c952a149f0431e3db30052f0cce8b930b579
7
+ data.tar.gz: 55b2d9b3f649b0969a86d10bfad2539e0ae138243930114488af9e24cb0c757d4c2296721c735469310ec1d4334a66ecb09a49b0dc6fb6dd83ae75292c65a17a
@@ -59,8 +59,7 @@ module SimpleTokenAuthentication
59
59
 
60
60
  # The finder method should be compatible with all the model adapters,
61
61
  # namely ActiveRecord and Mongoid in all their supported versions.
62
- record = nil
63
- record = identifier_param_value && entity.model.where(entity.identifier => identifier_param_value).first
62
+ identifier_param_value && entity.model.find_for_authentication(entity.identifier => identifier_param_value)
64
63
  end
65
64
 
66
65
  # Private: Take benefit from Devise case-insensitive keys
@@ -1,3 +1,3 @@
1
1
  module SimpleTokenAuthentication
2
- VERSION = "1.10.1"
2
+ VERSION = "1.11.0"
3
3
  end
@@ -24,14 +24,14 @@ describe 'Simple Token Authentication' do
24
24
  # given one *c*orrect record (which is supposed to get signed in)
25
25
  @charles_record = double()
26
26
  [user, admin].each do |model|
27
- allow(model).to receive(:where).with(email: 'charles@example.com').and_return([@charles_record])
27
+ allow(model).to receive(:find_for_authentication).with(email: 'charles@example.com').and_return(@charles_record)
28
28
  end
29
29
  allow(@charles_record).to receive(:authentication_token).and_return('ch4rlEs_toKeN')
30
30
 
31
31
  # and one *w*rong record (which should not be signed in)
32
32
  @waldo_record = double()
33
33
  [user, admin].each do |model|
34
- allow(model).to receive(:where).with(email: 'waldo@example.com').and_return([@waldo_record])
34
+ allow(model).to receive(:find_for_authentication).with(email: 'waldo@example.com').and_return(@waldo_record)
35
35
  end
36
36
  allow(@waldo_record).to receive(:authentication_token).and_return('w4LdO_toKeN')
37
37
 
@@ -401,12 +401,12 @@ describe 'Simple Token Authentication' do
401
401
 
402
402
  # given one *c*orrect record (which is supposed to get signed in)
403
403
  @charles_record = double()
404
- allow(user).to receive(:where).with(email: 'charles@example.com').and_return([@charles_record])
404
+ allow(user).to receive(:find_for_authentication).with(email: 'charles@example.com').and_return(@charles_record)
405
405
  allow(@charles_record).to receive(:authentication_token).and_return('ch4rlEs_toKeN')
406
406
 
407
407
  # and one *w*rong record (which should not be signed in)
408
408
  @waldo_record = double()
409
- allow(user).to receive(:where).with(email: 'waldo@example.com').and_return([@waldo_record])
409
+ allow(user).to receive(:find_for_authentication).with(email: 'waldo@example.com').and_return(@waldo_record)
410
410
  allow(@waldo_record).to receive(:authentication_token).and_return('w4LdO_toKeN')
411
411
 
412
412
  # given a controller class which acts as token authentication handler
@@ -213,8 +213,9 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
213
213
  it 'returns the proper record if any' do
214
214
  # let's say there is a record
215
215
  record = double()
216
- allow(@entity).to receive_message_chain(:model, :where).with(email: 'alice@example.com')
217
- .and_return([record])
216
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
217
+ .with(email: 'alice@example.com')
218
+ .and_return(record)
218
219
 
219
220
  expect(subject.new.send(:find_record_from_identifier, @entity)).to eq record
220
221
  end
@@ -231,11 +232,13 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
231
232
  # let's say there is a record...
232
233
  record = double()
233
234
  # ...whose identifier is downcased...
234
- allow(@entity).to receive_message_chain(:model, :where).with(email: 'alice@example.com')
235
- .and_return([record])
235
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
236
+ .with(email: 'alice@example.com')
237
+ .and_return(record)
236
238
  # ...not upcased
237
- allow(@entity).to receive_message_chain(:model, :where).with(email: 'AliCe@ExampLe.Com')
238
- .and_return([])
239
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
240
+ .with(email: 'AliCe@ExampLe.Com')
241
+ .and_return(nil)
239
242
 
240
243
  expect(subject.new.send(:find_record_from_identifier, @entity)).to be_nil
241
244
  end
@@ -259,8 +262,9 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
259
262
  it 'returns the proper record if any' do
260
263
  # let's say there is a record
261
264
  record = double()
262
- allow(@entity).to receive_message_chain(:model, :where).with(email: 'alice@example.com')
263
- .and_return([record])
265
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
266
+ .with(email: 'alice@example.com')
267
+ .and_return(record)
264
268
 
265
269
  expect(subject.new.send(:find_record_from_identifier, @entity)).to eq record
266
270
  end
@@ -277,12 +281,13 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
277
281
  # let's say there is a record...
278
282
  record = double()
279
283
  # ...whose identifier is downcased...
280
- allow(@entity).to receive_message_chain(:model, :where)
281
- allow(@entity).to receive_message_chain(:model, :where).with(email: 'alice@example.com')
282
- .and_return([record])
284
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
285
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
286
+ .with(email: 'alice@example.com')
287
+ .and_return(record)
283
288
  # ...not upcased
284
- allow(@entity).to receive_message_chain(:model, :where).with(email: 'AliCe@ExampLe.Com')
285
- .and_return([])
289
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication).with(email: 'AliCe@ExampLe.Com')
290
+ .and_return(nil)
286
291
 
287
292
  expect(subject.new.send(:find_record_from_identifier, @entity)).to eq record
288
293
  end
@@ -312,8 +317,9 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
312
317
  it 'returns the proper record if any' do
313
318
  # let's say there is a record
314
319
  record = double()
315
- allow(@entity).to receive_message_chain(:model, :where).with(phone_number: 'alice@example.com')
316
- .and_return([record])
320
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
321
+ .with(phone_number: 'alice@example.com')
322
+ .and_return(record)
317
323
 
318
324
  expect(subject.new.send(:find_record_from_identifier, @entity)).to eq record
319
325
  end
@@ -330,11 +336,13 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
330
336
  # let's say there is a record...
331
337
  record = double()
332
338
  # ...whose identifier is downcased...
333
- allow(@entity).to receive_message_chain(:model, :where).with(phone_number: 'alice@example.com')
334
- .and_return([record])
339
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
340
+ .with(phone_number: 'alice@example.com')
341
+ .and_return(record)
335
342
  # ...not upcased
336
- allow(@entity).to receive_message_chain(:model, :where).with(phone_number: 'AliCe@ExampLe.Com')
337
- .and_return([])
343
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
344
+ .with(phone_number: 'AliCe@ExampLe.Com')
345
+ .and_return(nil)
338
346
 
339
347
  expect(subject.new.send(:find_record_from_identifier, @entity)).to be_nil
340
348
  end
@@ -358,8 +366,9 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
358
366
  it 'returns the proper record if any' do
359
367
  # let's say there is a record
360
368
  record = double()
361
- allow(@entity).to receive_message_chain(:model, :where).with(phone_number: 'alice@example.com')
362
- .and_return([record])
369
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
370
+ .with(phone_number: 'alice@example.com')
371
+ .and_return(record)
363
372
 
364
373
  expect(subject.new.send(:find_record_from_identifier, @entity)).to eq record
365
374
  end
@@ -376,12 +385,14 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
376
385
  # let's say there is a record...
377
386
  record = double()
378
387
  # ...whose identifier is downcased...
379
- allow(@entity).to receive_message_chain(:model, :where)
380
- allow(@entity).to receive_message_chain(:model, :where).with(phone_number: 'alice@example.com')
381
- .and_return([record])
388
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
389
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
390
+ .with(phone_number: 'alice@example.com')
391
+ .and_return(record)
382
392
  # ...not upcased
383
- allow(@entity).to receive_message_chain(:model, :where).with(phone_number: 'AliCe@ExampLe.Com')
384
- .and_return([])
393
+ allow(@entity).to receive_message_chain(:model, :find_for_authentication)
394
+ .with(phone_number: 'AliCe@ExampLe.Com')
395
+ .and_return(nil)
385
396
 
386
397
  expect(subject.new.send(:find_record_from_identifier, @entity)).to eq record
387
398
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_token_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Bulnes Guilpain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -132,6 +132,20 @@ dependencies:
132
132
  - - "<"
133
133
  - !ruby/object:Gem::Version
134
134
  version: '5'
135
+ - !ruby/object:Gem::Dependency
136
+ name: tins
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "<"
140
+ - !ruby/object:Gem::Version
141
+ version: 1.7.0
142
+ type: :development
143
+ prerelease: false
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "<"
147
+ - !ruby/object:Gem::Version
148
+ version: 1.7.0
135
149
  description:
136
150
  email:
137
151
  - gon.bulnes@gmail.com
@@ -198,7 +212,7 @@ files:
198
212
  - spec/support/specs_for_token_authentication_handler_interface.rb
199
213
  homepage: https://github.com/gonzalo-bulnes/simple_token_authentication
200
214
  licenses:
201
- - GPLv3
215
+ - GPL-3.0+
202
216
  metadata: {}
203
217
  post_install_message:
204
218
  rdoc_options: []
@@ -216,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
230
  version: '0'
217
231
  requirements: []
218
232
  rubyforge_project:
219
- rubygems_version: 2.5.0
233
+ rubygems_version: 2.5.1
220
234
  signing_key:
221
235
  specification_version: 4
222
236
  summary: Simple (but safe) token authentication for Rails apps or API with Devise.