app_rail-airtable 0.4.1 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
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,9 +1,10 @@
|
|
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
|
+
app_rail-steps
|
7
8
|
bcrypt
|
8
9
|
faraday (~> 2.2)
|
9
10
|
faraday-net_http_persistent (~> 2.0)
|
@@ -13,15 +14,16 @@ PATH
|
|
13
14
|
GEM
|
14
15
|
remote: https://rubygems.org/
|
15
16
|
specs:
|
16
|
-
activesupport (7.0.2.
|
17
|
+
activesupport (7.0.2.4)
|
17
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
19
|
i18n (>= 1.6, < 2)
|
19
20
|
minitest (>= 5.1)
|
20
21
|
tzinfo (~> 2.0)
|
21
|
-
airrecord (1.0.
|
22
|
-
faraday (>= 0
|
22
|
+
airrecord (1.0.10)
|
23
|
+
faraday (>= 1.0, < 3.0)
|
23
24
|
faraday-net_http_persistent
|
24
25
|
net-http-persistent
|
26
|
+
app_rail-steps (0.2.9)
|
25
27
|
bcrypt (3.1.17)
|
26
28
|
byebug (11.1.3)
|
27
29
|
concurrent-ruby (1.1.10)
|
data/app_rail-airtable.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
spec.add_dependency 'activesupport'
|
30
30
|
spec.add_dependency 'airrecord'
|
31
|
+
spec.add_dependency 'app_rail-steps'
|
31
32
|
spec.add_dependency 'bcrypt'
|
32
33
|
spec.add_dependency 'faraday', '~> 2.2'
|
33
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,14 +1,14 @@
|
|
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
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: app_rail-steps
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bcrypt
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|