rsvp 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODU3YTY1Y2UwZmVjZTllMjJiNzI2ZWE2ZDQyYzNhZTAyMjE3NjM0OA==
4
+ NDQ3Y2M4YzcwMTI4ZjA3YTk3ZjNmOTQzOTMwNDQ1YzY4NTA4N2ZmZQ==
5
5
  data.tar.gz: !binary |-
6
- OGRhMjNmNTZmZjRiZWExNjczY2FkODA3NjQwNTBkYzQxNjg3YzgwNw==
6
+ Mjg5MWZjYTZhNmY3MjBmMWJlZTM2YWZmZDY0NjgwMmU5ZWVmZmI1Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzA5ZTdhZGI3Y2VjZmFmMDJhYTFlYmZhM2Y1OTA0NWYyMGQzZWQwMjJiMWQ4
10
- NWViMmE3OTM2MGM4ZmNmNzA0YjUxMjgzYWY5MTMwZDU3MDIxNmUyZGVhNGJj
11
- N2RkYjA1NDE3ZDQ4NjMzNThiOGE2MDY2YzFmNjFhYWQ5ZTcwOWY=
9
+ ZTFiMmQxZmExNzc5ZWM1ZmNhNzRhZTFmYWJkMTAxNTIxMzgyYTA0NmM2YzU3
10
+ YTBjMjEyYTliZmU1MTQwMTRlODQyNTRmZGEyZmU2NDg3MTZkN2YyZjFlNzgw
11
+ MjJjMzBkY2QxZmNhMjU3ZTEyODU1ODkwNDA5NmU3MzZlZGUzZTA=
12
12
  data.tar.gz: !binary |-
13
- MTA0NzlhZmZhZDk1MDE2ZWY1YWIyOWE5MWQzNTMxY2MyZDk1ZDQ2YTZhNTA3
14
- ZjUyYjIxYTg0MjBiOWEwM2U1MjdlOTI1MWFhZmE2MDVlNzZkYWY3OTU2ZDg5
15
- ZjViZGUxZGU4NmZhMTllMzFiMWY4YjcwZmEwNzA3YmE1Mzg5Nzk=
13
+ ODZiZWE2NzU0M2I5YWRlNGE5MzljMDk2NzIwYTI1NzYzMDNmNjZhYzVjMGJl
14
+ ZTQxNTJhNzcyN2NkNDNkOGFiMDY0Mzk2Mjk0OTg4MjM0ZjIxNGYzMTIyNDU5
15
+ ZjkwYjNiMmFhNmE1MTdkNWJkNWUyMDk0ZTVkMDVhMmNiMDE4MmE=
@@ -2,7 +2,8 @@ module Rsvp
2
2
  class SessionController < ApplicationController
3
3
  skip_before_filter :require_session, :only => [:index, :create]
4
4
  before_filter :get_access_attempt
5
- before_filter :redirect_locked, :only => [:create]
5
+ before_filter :flash_message_when_locked, :only => [:index]
6
+ before_filter :redirect_when_locked, :only => [:create]
6
7
 
7
8
  # GET /session
8
9
  def index; end
@@ -14,9 +15,12 @@ module Rsvp
14
15
  session[:invitation_id] = invitation.id
15
16
  redirect_to (invitation.responses.any? ? show_response_index_path : response_index_path)
16
17
  else
17
- record_failed_access_attempt
18
- flash.alert = "Oops!! The code you entered is not valid. Please try again."
19
- redirect_to root_path
18
+ if exceeded_access_attempts?
19
+ redirect_when_locked
20
+ else
21
+ flash.alert = "Oops!! The code you entered is not valid. Please try again."
22
+ redirect_to root_path
23
+ end
20
24
  end
21
25
  end
22
26
 
@@ -37,15 +41,21 @@ module Rsvp
37
41
  @access_attempt ||= AccessAttempt.find_or_create_by(remote_ip: request.remote_ip)
38
42
  end
39
43
 
40
- def record_failed_access_attempt
44
+ def exceeded_access_attempts?
41
45
  @access_attempt.record_attempt
46
+ @access_attempt.locked?
42
47
  end
43
48
 
44
- def redirect_locked
49
+ def redirect_when_locked
45
50
  if @access_attempt.locked?
46
- flash[:alert] = "You surpassed the attempt threshold. You may try again on #{@access_attempt.locked_until.strftime('%B %d at %I:%M %p')}."
47
51
  redirect_to root_path
48
52
  end
49
53
  end
54
+
55
+ def flash_message_when_locked
56
+ if @access_attempt.locked?
57
+ flash.now[:alert] = "You surpassed the attempt threshold. You may try again on #{@access_attempt.locked_until.strftime('%A, %B %d at %l:%M %p').gsub(/[\ ]{2}/, " ")}."
58
+ end
59
+ end
50
60
  end
51
61
  end
@@ -1,5 +1,7 @@
1
- <%= form_tag sign_in_path, :method => :post do |f| %>
2
- <%= label_tag :rsvp_code, "Enter your RSVP Code" %>
3
- <%= text_field_tag :rsvp_code %>
4
- <%= submit_tag "Begin RSVP" %>
1
+ <% unless @access_attempt.locked? %>
2
+ <%= form_tag sign_in_path, :method => :post do |f| %>
3
+ <%= label_tag :rsvp_code, "Enter your RSVP Code" %>
4
+ <%= text_field_tag :rsvp_code %>
5
+ <%= submit_tag "Begin RSVP" %>
6
+ <% end %>
5
7
  <% end %>
data/lib/rsvp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rsvp
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsvp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ricard