app_rail-airtable 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/app_rail-airtable.gemspec +1 -1
- data/lib/app_rail/airtable/authenticatable.rb +9 -1
- data/lib/app_rail/airtable/sinatra.rb +11 -3
- data/lib/app_rail/airtable/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bdf887a34ccfd9c7954686766bab870a20c4374aa5f88a7e8e11a01d62430a4
|
4
|
+
data.tar.gz: b835884ff719353097b0d70277c52b1bda4bc5bf9ed23008ee9b0005bce1354c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0c589cae34adf401da10ef37daa174ff9eec6e8a9c5b93c5bc632059e52f41be0e685001ae3d9fe29e837678adf1709c7509cabb5dbe37af1f7438a5780afcb
|
7
|
+
data.tar.gz: e48ced1c4155d951decd90d83a38c371e4d50a135a29320c21f723ede9a4e535561fe302faf68b9a3a0256aa89e8f957c77e36f2096431f35551c6f132a618c2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_rail-airtable (0.4.
|
4
|
+
app_rail-airtable (0.4.4)
|
5
5
|
activesupport
|
6
6
|
airrecord
|
7
7
|
app_rail-steps
|
@@ -14,16 +14,16 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
activesupport (7.0.2.
|
17
|
+
activesupport (7.0.2.4)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 1.6, < 2)
|
20
20
|
minitest (>= 5.1)
|
21
21
|
tzinfo (~> 2.0)
|
22
|
-
airrecord (1.0.
|
23
|
-
faraday (>= 0
|
22
|
+
airrecord (1.0.10)
|
23
|
+
faraday (>= 1.0, < 3.0)
|
24
24
|
faraday-net_http_persistent
|
25
25
|
net-http-persistent
|
26
|
-
app_rail-steps (0.2.
|
26
|
+
app_rail-steps (0.2.9)
|
27
27
|
bcrypt (3.1.17)
|
28
28
|
byebug (11.1.3)
|
29
29
|
concurrent-ruby (1.1.10)
|
data/app_rail-airtable.gemspec
CHANGED
@@ -26,9 +26,9 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables << 'ara_generator'
|
27
27
|
|
28
28
|
spec.require_paths = ['lib']
|
29
|
-
spec.add_dependency 'app_rail-steps'
|
30
29
|
spec.add_dependency 'activesupport'
|
31
30
|
spec.add_dependency 'airrecord'
|
31
|
+
spec.add_dependency 'app_rail-steps'
|
32
32
|
spec.add_dependency 'bcrypt'
|
33
33
|
spec.add_dependency 'faraday', '~> 2.2'
|
34
34
|
spec.add_dependency 'faraday-net_http_persistent', '~> 2.0' # workaround to make Faraday work after upgrading to 2.2.0
|
@@ -6,6 +6,8 @@ require 'securerandom'
|
|
6
6
|
module AppRail
|
7
7
|
module Airtable
|
8
8
|
module Authenticatable
|
9
|
+
class AlreadyExistsError < StandardError; end
|
10
|
+
|
9
11
|
include BCrypt
|
10
12
|
|
11
13
|
def self.included(klass)
|
@@ -15,6 +17,8 @@ module AppRail
|
|
15
17
|
|
16
18
|
module ClassMethods
|
17
19
|
def create(email:, password:)
|
20
|
+
raise AlreadyExistsError if find_by_email(email)
|
21
|
+
|
18
22
|
user = new('Email' => email, 'Password Hash' => password_hash(password), 'Access Token' => next_access_token)
|
19
23
|
user.create
|
20
24
|
user
|
@@ -30,10 +34,14 @@ module AppRail
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def find_by_email_and_password(email, password)
|
33
|
-
user =
|
37
|
+
user = find_by_email(email)
|
34
38
|
user&.valid_password?(password) ? user : nil
|
35
39
|
end
|
36
40
|
|
41
|
+
def find_by_email(email)
|
42
|
+
all(filter: "{Email} = \"#{email}\"").first
|
43
|
+
end
|
44
|
+
|
37
45
|
def find_by_access_token(access_token)
|
38
46
|
all(filter: "{Access Token} = \"#{access_token}\"").first
|
39
47
|
end
|
@@ -12,6 +12,10 @@ class Symbol
|
|
12
12
|
ActiveSupport::Inflector.pluralize(self)
|
13
13
|
end
|
14
14
|
|
15
|
+
def singularize
|
16
|
+
ActiveSupport::Inflector.singularize(self)
|
17
|
+
end
|
18
|
+
|
15
19
|
def classify
|
16
20
|
ActiveSupport::Inflector.classify(self)
|
17
21
|
end
|
@@ -77,9 +81,13 @@ module AppRail
|
|
77
81
|
def self.create_route(name, authenticated_route)
|
78
82
|
post "/#{name}" do
|
79
83
|
authenticate! if authenticated_route
|
80
|
-
|
81
|
-
|
82
|
-
|
84
|
+
begin
|
85
|
+
as_json = name.classify_constantize.create_as_json(current_user: authenticated_route ? current_user : nil,
|
86
|
+
params: params_and_body_as_json)
|
87
|
+
[201, as_json.to_json]
|
88
|
+
rescue AppRail::Airtable::Authenticatable::AlreadyExistsError
|
89
|
+
[422, { error: "#{name.singularize} already exists" }]
|
90
|
+
end
|
83
91
|
end
|
84
92
|
end
|
85
93
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_rail-airtable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brooke-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: airrecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: app_rail-steps
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|