ruby_auth_metamask 0.2.1 → 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: cb5e4bf73f7fdda470104808479940ea4e819fe158b128b0942ad45d1a4be3ca
4
- data.tar.gz: 3d58e18914600f5f0e047636c9bba4b6e23cd1fd88dc367ebb86fc0fe965b501
3
+ metadata.gz: 1a362ca429634dbf653e1a071640c52731729e774b2bd385f3a760dc8f8a2a4b
4
+ data.tar.gz: 64d2b043d60f2da7f75446db0aa83008d15322187373afa29316bd1d09dddf5c
5
5
  SHA512:
6
- metadata.gz: ed3527440701177de6bd46563b950de79b35529d7a6e154c83c064a52193d3bca642ff9261063cc969579b283d1ac98100f7f8fd5bfa6282b09dcc0d47db045b
7
- data.tar.gz: e4bfa9c34243717186d3ab590c816419dc71c284b8f344f7b4e07ab0b690c684ebe27a2fd1c642526fcaf283956e53799c898028546af02239b6f52a81e71dd8
6
+ metadata.gz: 80ab219b6aadbc2c75b92950253f049dd78c48f75335edce429530174f3a781ff290eb5b1564130fe90707c0184c880e1682a50b855b2318c745912ec4243a88
7
+ data.tar.gz: b12935258760428718c8d325b65320cac6c3eacc8c3cdc8b24ba4bf672e31971f95b4f3eb199d3daad0fa74a408df7359a1d4237379ac906fe61ed000d299ea5
@@ -14,8 +14,12 @@ module RubyAuthMetamask
14
14
 
15
15
  class UsersController < ApplicationController
16
16
  def signin
17
- @message = "ruby_auth_metamask:#{SecureRandom.hex}"
18
- session[:message] = @message
17
+ if session[:user_id].nil?
18
+ @message = "ruby_auth_metamask:#{SecureRandom.hex}"
19
+ session[:message] = @message
20
+ else
21
+ redirect_to main_app.root_path
22
+ end
19
23
  end
20
24
 
21
25
  def verify
@@ -44,11 +48,11 @@ module RubyAuthMetamask
44
48
  end
45
49
 
46
50
  valid = ECDSA.valid_signature?(public_key, hash, my_signature.sig_obj) rescue false
47
- if valid
48
- redirect_to main_app.root_path, notice: 'User authenticated successfully'
49
- else
50
- redirect_to main_app.root_path, notice: 'User authentication failed'
51
- end
51
+ redirect_to main_app.root_path, notice: 'User authentication failed' unless valid
52
+
53
+ user = User.find_by_address(address) || User.create(address: address)
54
+ session[:user_id] = user.id
55
+ redirect_to main_app.root_path, notice: 'User authentication succeeded'
52
56
  end
53
57
 
54
58
  private
@@ -1,3 +1,3 @@
1
1
  module RubyAuthMetamask
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_auth_metamask
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Zhang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-17 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: ecdsa
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: keccak
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.3.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.3.1
55
55
  description: This is a Ruby on Rails Engine. It authenticates users against their
56
56
  metamask signature.
57
57
  email: