app_rail-airtable 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +3 -1
- data/app_rail-airtable.gemspec +1 -0
- data/lib/app_rail/airtable/authentication_record.rb +27 -0
- data/lib/app_rail/airtable/version.rb +1 -1
- data/lib/app_rail/airtable.rb +2 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e09f5f21d40b2186a9b4d985d85305c0f4e54e4066d74ee45a5c43a32a303ad
|
4
|
+
data.tar.gz: 0ab6b313e24780b1f83e2359638e783ff3d7ca7b6958b14c7c80ba479262e07c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cdd4ff73e660d69000ac91e1204047f7637a7d58e351e1253639a60423828ccf3c8417083aeaadf1d4d3660584302cbfab9a39f5f737a5b501257fdf6f0359e
|
7
|
+
data.tar.gz: b9e534d2132bf753fd8cdf8d1126cdf629921177bbaf164e6ca21cabd64b9b207830dcbc9087a09f480c03d0c5ebb8e0101a8ae1d6625da851dc8bc8e589eee3
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_rail-airtable (0.2.
|
4
|
+
app_rail-airtable (0.2.9)
|
5
5
|
activesupport
|
6
6
|
airrecord
|
7
|
+
bcrypt
|
7
8
|
sinatra
|
8
9
|
thor
|
9
10
|
|
@@ -19,6 +20,7 @@ GEM
|
|
19
20
|
airrecord (1.0.7)
|
20
21
|
faraday (>= 0.10, < 2.0)
|
21
22
|
net-http-persistent
|
23
|
+
bcrypt (3.1.16)
|
22
24
|
byebug (11.1.3)
|
23
25
|
concurrent-ruby (1.1.9)
|
24
26
|
connection_pool (2.2.5)
|
data/README.md
CHANGED
@@ -31,7 +31,9 @@ You should create a model class for each table you want to use in your App. Mode
|
|
31
31
|
To provide support for routes, models can implement
|
32
32
|
* ar_list_item (index)
|
33
33
|
* ar_stack (show)
|
34
|
-
* self.create_as_json (create)
|
34
|
+
* self.create_as_json (create)
|
35
|
+
|
36
|
+
In order to support authentication you should create a class (normally `User`) and inherit from `AppRail::Airtable::AuthenticationRecord`. Your table needs `Email`, `Password Hash` and `Access Token` columns.
|
35
37
|
|
36
38
|
### Servers
|
37
39
|
You should create a single server which extends `AppRail::Airtable::Sinatra`, then add routes with the `resources` macro to add `index`, `show` and `create` routes. You can also provide your own routes.
|
data/app_rail-airtable.gemspec
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bcrypt'
|
2
|
+
|
3
|
+
module AppRail
|
4
|
+
module Airtable
|
5
|
+
class AuthenticationRecord < ApplicationRecord
|
6
|
+
include BCrypt
|
7
|
+
airtable_attr "Email", "Password Hash", "Access Token"
|
8
|
+
|
9
|
+
def self.create_session_as_json(email:, password:)
|
10
|
+
user = find_by_email_and_password(email, Password.create(password))
|
11
|
+
user&.oauth_session
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_by_email_and_password(email, password_hash)
|
15
|
+
all(filter: "AND({Email} = \"#{email}\",{Password Hash} = \"#{password_hash}\")").first
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_by_access_token(access_token)
|
19
|
+
all(filter: "{Access Token} = \"#{access_token}\"").first
|
20
|
+
end
|
21
|
+
|
22
|
+
def oauth_session
|
23
|
+
{ access_token: self["Access Token"], scope: :user, refresh_token: "", token_type: :bearer, expires_in: 60000 }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/app_rail/airtable.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require "app_rail/airtable/version"
|
2
|
+
require "app_rail/airtable/string_ext"
|
2
3
|
require "app_rail/airtable/application_record"
|
4
|
+
require "app_rail/airtable/authentication_record"
|
3
5
|
require "app_rail/airtable/sinatra"
|
4
6
|
require "app_rail/airtable/generator"
|
5
|
-
require "app_rail/airtable/string_ext"
|
6
7
|
|
7
8
|
module AppRail
|
8
9
|
module Airtable
|
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.2.
|
4
|
+
version: 0.2.9
|
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: 2021-10-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bcrypt
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +130,7 @@ files:
|
|
116
130
|
- bin/setup
|
117
131
|
- lib/app_rail/airtable.rb
|
118
132
|
- lib/app_rail/airtable/application_record.rb
|
133
|
+
- lib/app_rail/airtable/authentication_record.rb
|
119
134
|
- lib/app_rail/airtable/generator.rb
|
120
135
|
- lib/app_rail/airtable/sinatra.rb
|
121
136
|
- lib/app_rail/airtable/string_ext.rb
|