devise_code_authenticatable 0.1.7 → 0.2.3
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2948fdbc5b0bc87a1d08ab431cee7d121abbec208a82836f8662216341d575c7
|
4
|
+
data.tar.gz: e08fee0dbc98b94e9b368dad6a96b41741698e7c9e9e802847c4ba556199732c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34bf27cd625727f12d09d1cefde526810274493d93db5cd42ce6d82ebe5e1944d5472e6950466d20850f53a369aace9ab61a3b87a9265404982f79b2167c587c
|
7
|
+
data.tar.gz: 3b38efb389db6397e7818be56451ceaa7cfbb5dc4c1b4cdea87701ea7754589a2fea2476ee447a05c3bacacdf76d5ffd121ae75f2690c9b65873004377134e89
|
data/README.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# DeviseCodeAuthenticatable
|
2
2
|
A Devise plugin for two-factor authenticatable.
|
3
3
|
|
4
|
-
## Demo
|
5
|
-
An example rails app to use this plugin is setup in [demo](https://github.com/vincentying15/demo_for_devise_code_authenticatable)
|
6
|
-
|
7
4
|
## Installation
|
8
5
|
Add this line to your Rails Gemfile:
|
9
6
|
|
@@ -11,20 +8,18 @@ Add this line to your Rails Gemfile:
|
|
11
8
|
gem 'devise_code_authenticatable'
|
12
9
|
```
|
13
10
|
|
14
|
-
### Automatic installation
|
15
11
|
Run:
|
16
12
|
|
17
13
|
```bash
|
18
14
|
rails generate devise_code_authenticatable:install
|
19
15
|
```
|
20
16
|
|
21
|
-
This will create a migration file
|
17
|
+
This will create a migration file in your `db/migrate` folder, then
|
22
18
|
|
23
19
|
|
24
20
|
```ruby
|
25
21
|
rails db:migrate
|
26
22
|
```
|
27
|
-
### Devise Configuration
|
28
23
|
Add `:authenticatable` to the model you want to enable code_authenticatable, also make sure `:database_authenticatable` is removed
|
29
24
|
|
30
25
|
```ruby
|
@@ -29,8 +29,8 @@ module DeviseCodeAuthenticatable
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def expired?
|
32
|
-
retry_time_limit =
|
33
|
-
expire_at = (self.created_at || Time.now) +
|
32
|
+
retry_time_limit = self.class.retry_limit
|
33
|
+
expire_at = (self.created_at || Time.now) + self.class.expire_time
|
34
34
|
|
35
35
|
self.expired = self.expired || Time.now.after?(expire_at) || self.retry_times.to_i > retry_time_limit
|
36
36
|
end
|
@@ -40,7 +40,8 @@ module DeviseCodeAuthenticatable
|
|
40
40
|
end
|
41
41
|
|
42
42
|
module ClassMethods
|
43
|
-
Devise::Models.config(self, :
|
43
|
+
Devise::Models.config(self, :retry_limit)
|
44
|
+
Devise::Models.config(self, :expire_time)
|
44
45
|
end
|
45
46
|
|
46
47
|
end
|
@@ -16,6 +16,20 @@ require 'devise_code_authenticatable/rails'
|
|
16
16
|
require 'devise_code_authenticatable/strategies/code_authenticatable'
|
17
17
|
|
18
18
|
module Devise
|
19
|
+
# Public: Maximum retry times for a code to be verifed (default: 5).
|
20
|
+
# Login code will not change even if user click resend mail,
|
21
|
+
# and the same code will be sent again.
|
22
|
+
#
|
23
|
+
# config.retry_limit = 1 # => The code will be reset immediately when user passed wrong code
|
24
|
+
mattr_accessor :retry_limit
|
25
|
+
@@retry_limit = 5
|
26
|
+
|
27
|
+
# Public: Deadline for a code to be verifed (default: 10.minutes).
|
28
|
+
# Login code will expired if user has not enter the login_code in 10 minutes
|
29
|
+
#
|
30
|
+
# config.expire_time = 1.hour # => The code is valid in the next hour after generated
|
31
|
+
mattr_accessor :expire_time
|
32
|
+
@@expire_time = 10.minutes
|
19
33
|
end
|
20
34
|
|
21
35
|
|
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_code_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vincentying15
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.2
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 6.0.2.1
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0.2
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 6.0.2.1
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
33
13
|
description: Devise plugin to allow sign in by email sent code
|
34
14
|
email:
|
35
15
|
- vincent_ying_live@outlook.com
|
@@ -70,7 +50,7 @@ licenses:
|
|
70
50
|
metadata:
|
71
51
|
allowed_push_host: https://rubygems.org
|
72
52
|
source_code_uri: https://github.com/vincentying15/devise_code_authenticatable
|
73
|
-
post_install_message:
|
53
|
+
post_install_message:
|
74
54
|
rdoc_options: []
|
75
55
|
require_paths:
|
76
56
|
- lib
|
@@ -85,8 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
65
|
- !ruby/object:Gem::Version
|
86
66
|
version: '0'
|
87
67
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
89
|
-
signing_key:
|
68
|
+
rubygems_version: 3.1.6
|
69
|
+
signing_key:
|
90
70
|
specification_version: 4
|
91
71
|
summary: devise_code_authenticatable
|
92
72
|
test_files: []
|