nyauth 0.7.0 → 0.7.1

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: b6eb0f450c4f26f25159c12c32d0c13caefb0982
4
- data.tar.gz: e393da8db0e0fc91a59a5a1e80d91943e801160b
3
+ metadata.gz: f36d29cbcc92d7492f72e337dee64bbfe33a9666
4
+ data.tar.gz: 05e5541213f6de68c1dd6af716fba67dfb399f5b
5
5
  SHA512:
6
- metadata.gz: 191a1a5e3900a560fc841f472a48c471779f8aa6c29555b09faba4a791e6e6a4edd609fcf2d154f89b1fda48ef050ca2c3f15bccec8fdce035accc07b5962577
7
- data.tar.gz: 7bfa56e198e0cb751c5626464e37a68073b9a87c915fbec010f17de9859de71d6637fa510ab5dc13bc601798dfc68d1a9010fdcec18327d1247bd6fc0ea49ebd
6
+ metadata.gz: 600804a6b8d4f09ebb1e9f6b448257ea8a6f2a5e43eb7d6349ecd7914ab616fe0fca9202611cd15855754e4c060c158d1ad7625fd29376fe197e336186793cf1
7
+ data.tar.gz: 78e26daa669e47d6c64daa9b21ce1859bcd55e1f908f26b0005a3bb3ad78a28f5515cc3980a7ebe9934abc20b6aafde5cfabc5dea240a59b84c4bafb23dad3aa
@@ -8,7 +8,6 @@ module Nyauth
8
8
 
9
9
  def update
10
10
  @client.attributes = client_params
11
- @client.password_digest_will_change! # HACK for Rails5beta2 https://github.com/rails/rails/issues/23645
12
11
  @client.save(context: :update_password)
13
12
  respond_with(@client, location: Nyauth.configuration.redirect_path_after_update_password.call(nyauth_client_name) || main_app.root_path)
14
13
  end
@@ -6,15 +6,22 @@ module Nyauth
6
6
 
7
7
  included do
8
8
  validates :email, presence: true
9
+ scope :with_given_email, -> (given_email) {
10
+ where(email: given_email)
11
+ }
9
12
  end
10
13
 
11
14
  module ClassMethods
12
15
  def authenticate(given_email, given_password)
13
- record = where(email: given_email).last
16
+ record = candidate_for_authentication(given_email)
14
17
  return nil unless record
15
18
 
16
19
  record.verify_password?(given_password) ? record : nil
17
20
  end
21
+
22
+ def candidate_for_authentication(given_email)
23
+ with_given_email(given_email).last
24
+ end
18
25
  end
19
26
  end
20
27
  end
@@ -10,7 +10,7 @@ module Nyauth
10
10
  def save(options = {})
11
11
  options.reverse_merge!(as: :user)
12
12
  klass = options[:as].to_s.classify.constantize
13
- @client = klass.find_by!(email: @email)
13
+ @client = klass.with_given_email(@email).last!
14
14
  @client.request_confirmation
15
15
  rescue
16
16
  errors.add(:base, :invalid_email)
@@ -10,7 +10,7 @@ module Nyauth
10
10
  def save(options = {})
11
11
  options.reverse_merge!(as: :user)
12
12
  klass = options[:as].to_s.classify.constantize
13
- @client = klass.find_by!(email: @email)
13
+ @client = klass.with_given_email(@email).last!
14
14
  @client.request_reset_password
15
15
  rescue
16
16
  errors.add(:base, :invalid_email)
@@ -1,3 +1,3 @@
1
1
  module Nyauth
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ppworks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails