devise-web3 0.2.0 → 0.4.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/app/controllers/devise/nonces_controller.rb +1 -1
- data/lib/devise/web3/config.rb +7 -0
- data/lib/devise/web3/engine.rb +0 -2
- data/lib/devise/web3/redis_store.rb +2 -2
- data/lib/devise/web3/strategies/web3_authenticatable.rb +1 -1
- data/lib/devise/web3/version.rb +1 -1
- data/lib/devise/web3.rb +5 -0
- data/lib/generators/active_record/devise_web3_generator.rb +19 -0
- data/lib/generators/active_record/templates/migration.rb +17 -0
- data/lib/generators/devise/web3/install_generator.rb +31 -0
- data/lib/generators/devise/web3/templates/install_config.rb +0 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b7d601a1bb5dbde83761481d45c26312a094bec9f2402492dcca3d0c6bd6ff1
|
4
|
+
data.tar.gz: 966885d97dfec348b2ddbb370eb54ed4ab136ef8fe95a228ae1fdde4fc17535c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feac226f0c0abc9049da5846035745521a63050fd24c3289e0db7a6e14ca8144db618ae8a79a303cab9bb4b60779b4db3f6df234d8b81b1600a18a11eb3720a3
|
7
|
+
data.tar.gz: 7f794ecd75037258717d9a7f4d6545e633c17daca0dacab2a9c92194e865c4a7560e29f3ae4f63e64715325137802d17be499da68cab4d537935c9cf9ccbe3ba
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,6 +31,11 @@ end
|
|
31
31
|
|
32
32
|
```
|
33
33
|
|
34
|
+
Generate migration
|
35
|
+
```shell
|
36
|
+
bin/rails g active_record:devise_web3 users
|
37
|
+
```
|
38
|
+
|
34
39
|
## Development
|
35
40
|
|
36
41
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/devise/web3/engine.rb
CHANGED
@@ -3,7 +3,7 @@ module Devise
|
|
3
3
|
module Strategies
|
4
4
|
class Web3Authenticatable < Authenticatable
|
5
5
|
def authenticate!
|
6
|
-
redis_store = Devise::Web3::RedisStore.new
|
6
|
+
redis_store = Devise::Web3::RedisStore.new
|
7
7
|
|
8
8
|
nonce = redis_store.fetch_nonce(nonce_id)
|
9
9
|
return fail!("Nonce coldn't be found. Perhaps it's already expired") if nonce.blank?
|
data/lib/devise/web3/version.rb
CHANGED
data/lib/devise/web3.rb
CHANGED
@@ -7,12 +7,17 @@ require 'devise/web3/engine'
|
|
7
7
|
require 'devise/web3/models/web3_authenticatable'
|
8
8
|
require 'devise/web3/strategies/web3_authenticatable'
|
9
9
|
require 'devise/web3/routes'
|
10
|
+
require 'devise/web3/config'
|
10
11
|
|
11
12
|
module Devise
|
13
|
+
def self.web3
|
14
|
+
yield(Devise::Web3::Config)
|
15
|
+
end
|
12
16
|
|
13
17
|
module Web3
|
14
18
|
class Error < StandardError; end
|
15
19
|
|
20
|
+
|
16
21
|
Devise.add_module :web3_authenticatable,
|
17
22
|
strategy: true,
|
18
23
|
model: 'devise/web3/models/web3_authenticatable',
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Generators
|
5
|
+
class DeviseWeb3Generator < ActiveRecord::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def copy_devise_migration
|
9
|
+
migration_template 'migration.rb', "db/migrate/devise_web3_add_to_#{table_name}.rb", migration_version: migration_version
|
10
|
+
end
|
11
|
+
|
12
|
+
def migration_version
|
13
|
+
if Rails::VERSION::MAJOR >= 5
|
14
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class DeviseWeb3AddTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def up
|
3
|
+
change_table :<%= table_name %> do |t|
|
4
|
+
t.string :public_address
|
5
|
+
end
|
6
|
+
|
7
|
+
add_index :<%= table_name %>, :public_address
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
change_table :<%= table_name %> do |t|
|
12
|
+
t.remove :public_address
|
13
|
+
end
|
14
|
+
|
15
|
+
remove_index :<%= table_name %>, :public_address
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Devise
|
2
|
+
module Web3
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
desc 'Add DeviseInvitable config variables to the Devise initializer and copy DeviseInvitable locale files to your application.'
|
6
|
+
INSTALL_CONTENT = <<-CONTENT
|
7
|
+
# ==> Configuration for :web3_authenticatable
|
8
|
+
# config.web3 do |web3|
|
9
|
+
# web3.redis_url = nil
|
10
|
+
# end
|
11
|
+
|
12
|
+
CONTENT
|
13
|
+
|
14
|
+
def add_config_options_to_initializer
|
15
|
+
devise_initializer_path = 'config/initializers/devise.rb'
|
16
|
+
|
17
|
+
if File.exist?(devise_initializer_path)
|
18
|
+
old_content = File.read(devise_initializer_path)
|
19
|
+
|
20
|
+
if old_content.match(Regexp.new(/^\s # config.web3 do/))
|
21
|
+
say_status(:identical, "Configuration for :web3_authenticatable already exists", :blue)
|
22
|
+
else
|
23
|
+
inject_into_file(devise_initializer_path, before: " # ==> Configuration for :confirmable\n") do
|
24
|
+
INSTALL_CONTENT
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-web3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TheSmartnik
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-09-
|
10
|
+
date: 2025-09-13 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: devise
|
@@ -144,12 +144,17 @@ files:
|
|
144
144
|
- bin/setup
|
145
145
|
- devise-web3.gemspec
|
146
146
|
- lib/devise/web3.rb
|
147
|
+
- lib/devise/web3/config.rb
|
147
148
|
- lib/devise/web3/engine.rb
|
148
149
|
- lib/devise/web3/models/web3_authenticatable.rb
|
149
150
|
- lib/devise/web3/redis_store.rb
|
150
151
|
- lib/devise/web3/routes.rb
|
151
152
|
- lib/devise/web3/strategies/web3_authenticatable.rb
|
152
153
|
- lib/devise/web3/version.rb
|
154
|
+
- lib/generators/active_record/devise_web3_generator.rb
|
155
|
+
- lib/generators/active_record/templates/migration.rb
|
156
|
+
- lib/generators/devise/web3/install_generator.rb
|
157
|
+
- lib/generators/devise/web3/templates/install_config.rb
|
153
158
|
homepage: https://thesmartnik.com
|
154
159
|
licenses:
|
155
160
|
- MIT
|