mints 0.0.11 → 0.0.12

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: 57e9b1a288e9458592721e05c9f5ffcd4a54162f9d89624260eca3c0a881c8c9
4
- data.tar.gz: 9e95bc1ae4b48b2d819fd418446a0feae7a621c0fff47fc51504d8d2c827cf19
3
+ metadata.gz: 97aa9d0890796f3b8d99a99377253cdf6e94dedeb87a7048318073903fbfbe1d
4
+ data.tar.gz: 9e4e17583e943160852667e6fa853504818f6ba330529834416c4c2dc232bd85
5
5
  SHA512:
6
- metadata.gz: 2404e77a1f9f9dc8bd763c45ca9bbda31182768e41bb18edb9c69ec1a5087591cf85c14ca37379dff0c56437b4de035ae4feabc083e082a2174c28667cc49ea7
7
- data.tar.gz: 8e075f031ecdf7244dc36ed230152b185a549724a8a151de4507d55ddf30736f5719cb50637a9236b41d5e8a9f42d982fc071ab171b6899dd2b6adc4eb9cde15
6
+ metadata.gz: 762ab3452de8a7e288e51c498daf58141fe2b7068904f68b455871c87493b32943a3e0225b6b2a90e9bd3d87f1331995d82e207ac214b6c545440a2362122e4a
7
+ data.tar.gz: 14b2ccb45e7bf43d7c23e43708e2916970e11f49d117e8700e06ff0a00f5f0e7bbb2d7a42ab206879e670e524fb5c87677b4d71de518080026d84c3b23e432da
data/Gemfile CHANGED
File without changes
File without changes
data/lib/client.rb CHANGED
@@ -42,7 +42,7 @@ module Mints
42
42
  if full_url.match url
43
43
  time = group['time']
44
44
  url_need_cache = true
45
- @redis_server = Redis.new(host: config['redis_cache']['redis_host'])
45
+ @redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1)
46
46
  if @redis_server.get(full_url)
47
47
  response = @redis_server.get(full_url)
48
48
  result_from_cache = true
data/lib/contact.rb CHANGED
File without changes
@@ -2,12 +2,22 @@
2
2
  mints:
3
3
  host: http://your_host_goes_here.com
4
4
  api_key: your_mints_api_key_goes_here
5
+ mints_slug: slug_id #save id and token in redis
6
+ user_email: mints_user_email
7
+ user_password: mints_user_password
5
8
  redis_cache:
6
9
  use_cache: boolean_value_to_enable_and_disable_cache
7
- redis_host: your_redis_host
10
+ redis_host: your_redis_server_host
11
+ redis_port: your_redis_server_port
12
+ redis_db: your_redis_database
8
13
  groups:
9
14
  - urls:
10
15
  - group_of_urls
11
16
  time: time_that_will_be_applied_to_urls_in_seconds
12
17
  sdk:
13
- debug: false
18
+ debug: false
19
+ cookies_iframe:
20
+ activated: boolean_value_to_enable_and_disable_cookies_iframe
21
+ expire_time: expire_time_of_cookies_iframe_in_hours
22
+ hosts:
23
+ - array_of_host_to_send_cookies
File without changes
File without changes
File without changes
File without changes
data/lib/mints.rb CHANGED
@@ -2,6 +2,7 @@ require_relative "./pub.rb"
2
2
  require_relative "./contact.rb"
3
3
  require_relative "./user.rb"
4
4
  require_relative "./mints/controllers/base_controller.rb"
5
+ require_relative "./mints/controllers/base_api_controller.rb"
5
6
  require_relative "./mints/controllers/admin_base_controller.rb"
6
7
  require_relative "./mints/controllers/public_api_controller.rb"
7
8
  require_relative "./mints/controllers/contact_api_controller.rb"
File without changes
@@ -0,0 +1,53 @@
1
+ module Mints
2
+ class BaseApiController < ActionController::Base
3
+ before_action :set_mints_pub_client
4
+
5
+ ##
6
+ # === Mints Contact Login.
7
+ # Starts a contact session in mints.cloud and set a session cookie
8
+ def mints_contact_login(email, password)
9
+ # Login in mints
10
+ response = @mints_contact.login(email, password)
11
+ # Get session token from response
12
+ session_token = response['session_token']
13
+ id_token = response['contact']['id_token']
14
+ # Set a permanent cookie with the session token
15
+ cookies.permanent[:mints_contact_session_token] = session_token
16
+ cookies.permanent[:mints_contact_id] = id_token
17
+ @contact_token = id_token
18
+ end
19
+
20
+ ##
21
+ # === Mints Contact Logout.
22
+ # Destroy session from mints.cloud and delete local session cookie
23
+ def mints_contact_logout
24
+ # Logout from mints
25
+ @mints_contact.logout
26
+ # Delete local cookie
27
+ cookies.delete(:mints_contact_session_token)
28
+ cookies.delete(:mints_contact_id)
29
+ @contact_token = nil
30
+ end
31
+
32
+ private
33
+
34
+ ##
35
+ # === Set mints pub.
36
+ # Initialize the public client and set the contact token
37
+ def set_mints_pub_client
38
+ if File.exists?("#{Rails.root}/mints_config.yml.erb")
39
+ template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
40
+ config = YAML.load template.result(binding)
41
+ @host = config["mints"]["host"]
42
+ @api_key = config["mints"]["api_key"]
43
+ @debug = config["sdk"]["debug"] ? config["sdk"]["debug"] : false
44
+ else
45
+ raise 'MintsBadCredentialsError'
46
+ end
47
+ # Initialize mints pub client, credentials taken from mints_config.yml.erb file
48
+ @mints_pub = Mints::Pub.new(@host, @api_key, nil, @debug)
49
+ # Set contact token from cookie
50
+ @mints_pub.client.session_token = @contact_token
51
+ end
52
+ end
53
+ end
File without changes
@@ -80,7 +80,7 @@ module Mints
80
80
  config = YAML.load template.result(binding)
81
81
  @host = config["mints"]["host"]
82
82
  @api_key = config["mints"]["api_key"]
83
- @redis_server = Redis.new(host: config['redis_cache']['redis_host']) if config['redis_cache']['use_cache']
83
+ @redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1) if config['redis_cache']['use_cache']
84
84
  @redis_config = config['redis_cache']
85
85
  @use_cache = config['redis_cache']['use_cache']
86
86
  end
@@ -76,7 +76,7 @@ module Mints
76
76
  config = YAML.load template.result(binding)
77
77
  @host = config["mints"]["host"]
78
78
  @api_key = config["mints"]["api_key"]
79
- @redis_server = Redis.new(host: config['redis_cache']['redis_host']) if config['redis_cache']['use_cache']
79
+ @redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1) if config['redis_cache']['use_cache']
80
80
  @redis_config = config['redis_cache']
81
81
  @use_cache = config['redis_cache']['use_cache']
82
82
  end
@@ -80,7 +80,7 @@ module Mints
80
80
  config = YAML.load template.result(binding)
81
81
  @host = config["mints"]["host"]
82
82
  @api_key = config["mints"]["api_key"]
83
- @redis_server = Redis.new(host: config['redis_cache']['redis_host'])
83
+ @redis_server = Redis.new(host: config['redis_cache']['redis_host'], port: config['redis_cache']['redis_port'] ? config['redis_cache']['redis_port'] : 6379, db: config['redis_cache']['redis_db'] ? config['redis_cache']['redis_db'] : 1) if config['redis_cache']['use_cache']
84
84
  @redis_config = config['redis_cache']
85
85
  @use_cache = config['redis_cache']['use_cache'] if config['redis_cache']['use_cache']
86
86
  end
data/lib/pub.rb CHANGED
File without changes
data/lib/user.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Gomez Garcia, Omar Mora, Luis Payan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-30 00:00:00.000000000 Z
11
+ date: 2021-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -117,7 +117,7 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - Gemfile
120
- - Readme.md
120
+ - README.md
121
121
  - lib/client.rb
122
122
  - lib/contact.rb
123
123
  - lib/generators/mints_config.yml.erb
@@ -127,6 +127,7 @@ files:
127
127
  - lib/generators/mints_user_controller.rb
128
128
  - lib/mints.rb
129
129
  - lib/mints/controllers/admin_base_controller.rb
130
+ - lib/mints/controllers/base_api_controller.rb
130
131
  - lib/mints/controllers/base_controller.rb
131
132
  - lib/mints/controllers/contact_api_controller.rb
132
133
  - lib/mints/controllers/public_api_controller.rb