devise_imap_authenticatable 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,8 +20,9 @@ module Devise
20
20
  mattr_accessor :imap_ssl
21
21
  @@imap_ssl = false
22
22
 
23
- mattr_accessor :imap_mechanism
24
- @@imap_mechanism = "login"
23
+ mattr_accessor :imap_timeout
24
+ @@imap_timeout = 1
25
+
25
26
  end
26
27
 
27
28
  # Add imap_authenticatable module
@@ -1,4 +1,5 @@
1
1
  require 'net/imap'
2
+ require 'timeout'
2
3
 
3
4
  module Devise
4
5
 
@@ -8,9 +9,11 @@ module Devise
8
9
 
9
10
  def valid_credentials?(username, password)
10
11
  imap = new_connection
11
- imap.authenticate ::Devise.imap_mechanism, username, password
12
+ Timeout.timeout(::Devise.imap_timeout) do
13
+ imap.login username, password
14
+ end
12
15
  true
13
- rescue Net::IMAP::ResponseError
16
+ rescue Net::IMAP::ResponseError, Timeout::Error
14
17
  false
15
18
  ensure
16
19
  imap.try(:disconnect)
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module ImapAuthenticatable
3
- VERSION = "0.6.1" unless const_defined?(:VERSION)
3
+ VERSION = "0.6.2" unless const_defined?(:VERSION)
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_imap_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Medforth