lato 0.1.59 → 0.1.61

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: 4cc5abe2007e8028c5de1b2e4f76a4a9b93412e862059cb69b36e4940a37650f
4
- data.tar.gz: d89a0f0b13c2e994c063f6659f8e4456bbc695e701b0934d5686be005f0ca618
3
+ metadata.gz: dbce0bed99f54a95994491e950789841725ef0b4b5a87ecbee747de28a5b3357
4
+ data.tar.gz: 575538c21152ddf54ab612ca622c0d584fb0748841f2f9721bce38c23a6549b6
5
5
  SHA512:
6
- metadata.gz: 582c91f202e59201d654e1f3582070ee8c8a43797d44ca5c387a2732220b48c34487856175748eb4be480f418f94be3c4ee1abc03e601fbffef2b267f08957bd
7
- data.tar.gz: e3798419615b5a8ac29ba9e824ca2fa6fa030567902edda06e1ac0d890d36c57db14f878f3da75a498ee6238d32e796d04d43310d1f027f700a62fd2c3bd74e8
6
+ metadata.gz: 8d8c26a8af596b210841401c2b9c25cd1c3a5a83120b61f8fb30dda9d8e6d748cd1381425f8c4597e55ba0e97b01060e79179c1c879faa8e377f9d8e2b83d928
7
+ data.tar.gz: eb835a122d3e94d51efda3cae33865eaf9e37bdc6d1819469f24c097fefad04a5e4d3de5520a1fe07664f07b46d644678d7d6169b7013ee7dfc7db15b1fc7abe
@@ -20,13 +20,13 @@ export default class extends Controller {
20
20
  */
21
21
 
22
22
  disableSubmit() {
23
- if (!this.hasSubmitTarget) return
24
- this.submitTarget.setAttribute('disabled', true)
23
+ // if (!this.hasSubmitTarget) return
24
+ // this.submitTarget.setAttribute('disabled', true)
25
25
  }
26
26
 
27
27
  enableSubmit() {
28
- if (!this.hasSubmitTarget) return
29
- this.submitTarget.removeAttribute('disabled')
28
+ // if (!this.hasSubmitTarget) return
29
+ // this.submitTarget.removeAttribute('disabled')
30
30
  }
31
31
 
32
32
  loadFormData() {
@@ -30,6 +30,22 @@ module Lato
30
30
  false
31
31
  end
32
32
 
33
+ def limit_requests(limit = 10, time_window = 10.minutes)
34
+ cache_key = "Lato::Sessionable/limit_requests/#{controller_name}/#{action_name}/#{request.remote_ip}"
35
+ attempts = Rails.cache.read(cache_key) || 0
36
+
37
+ attempts += 1
38
+ Rails.cache.write(cache_key, attempts, expires_in: time_window)
39
+ return true unless attempts >= limit
40
+
41
+ respond_to do |format|
42
+ format.html { render plain: "Too many requests, please wait #{time_window.to_i / 60} minutes to retry.", status: :too_many_requests }
43
+ format.json { render json: {}, status: :too_many_requests }
44
+ end
45
+
46
+ false
47
+ end
48
+
33
49
  def session_create(user_id)
34
50
  cookies.encrypted[:lato_session] = { value: Lato::Session.generate_session_per_user(user_id), expires: Lato.config.session_lifetime.from_now }
35
51
  @session = Lato::Session.new(cookies.encrypted[:lato_session])
@@ -35,22 +35,6 @@ module Lato
35
35
  I18n.locale = @session.user.locale || I18n.default_locale
36
36
  end
37
37
 
38
- # This method limit the number of requests for a specific action.
39
- # Usage: before_action :limit_requests, only: %i[:action_name]
40
- def limit_requests(limit = 10, time_window = 10.minutes)
41
- cache_key = "Lato::ApplicationController.limit_requests/#{controller_name}/#{action_name}/#{request.remote_ip}"
42
- attempts = Rails.cache.read(cache_key) || 0
43
-
44
- attempts += 1
45
- Rails.cache.write(cache_key, attempts, expires_in: time_window)
46
- return unless attempts >= limit
47
-
48
- respond_to do |format|
49
- format.html { render plain: "Too many requests, please wait #{time_window.to_i / 60} minutes to retry.", status: :too_many_requests }
50
- format.json { render json: {}, status: :too_many_requests }
51
- end
52
- end
53
-
54
38
  def respond_to_with_not_found
55
39
  respond_to do |format|
56
40
  format.html { render plain: '', status: :not_found }
@@ -6,7 +6,7 @@ module Lato
6
6
 
7
7
  before_action :find_user, only: %i[verify_email verify_email_action update_password update_password_action]
8
8
  before_action :find_invitation, only: %i[accept_invitation accept_invitation_action]
9
-
9
+
10
10
  before_action :lock_signup_if_disabled, only: %i[signup signup_action]
11
11
  before_action :lock_recover_password_if_disabled, only: %i[recover_password recover_password_action update_password update_password_action]
12
12
 
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "0.1.59"
2
+ VERSION = "0.1.61"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.59
4
+ version: 0.1.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-24 00:00:00.000000000 Z
11
+ date: 2023-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  requirements: []
231
- rubygems_version: 3.2.19
231
+ rubygems_version: 3.4.1
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: Basic engine for all Lato projects