door_mat 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +3 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +88 -0
  6. data/Rakefile +32 -0
  7. data/app/assets/javascripts/door_mat/application.js +13 -0
  8. data/app/assets/stylesheets/door_mat/application.css +15 -0
  9. data/app/assets/stylesheets/scaffold.css +56 -0
  10. data/app/controllers/door_mat/activities_controller.rb +106 -0
  11. data/app/controllers/door_mat/application_controller.rb +14 -0
  12. data/app/controllers/door_mat/change_password_controller.rb +32 -0
  13. data/app/controllers/door_mat/forgot_passwords_controller.rb +57 -0
  14. data/app/controllers/door_mat/manage_email_controller.rb +61 -0
  15. data/app/controllers/door_mat/password_less_session_controller.rb +121 -0
  16. data/app/controllers/door_mat/reconfirm_password_controller.rb +27 -0
  17. data/app/controllers/door_mat/sessions_controller.rb +17 -0
  18. data/app/controllers/door_mat/sign_in_controller.rb +60 -0
  19. data/app/controllers/door_mat/sign_up_controller.rb +59 -0
  20. data/app/controllers/door_mat/static_controller.rb +5 -0
  21. data/app/mailers/door_mat/activity_mailer.rb +18 -0
  22. data/app/mailers/door_mat/password_less_session_mailer.rb +12 -0
  23. data/app/models/door_mat/access_token.rb +315 -0
  24. data/app/models/door_mat/activity.rb +14 -0
  25. data/app/models/door_mat/activity_confirm_email.rb +45 -0
  26. data/app/models/door_mat/activity_download_recovery_key.rb +30 -0
  27. data/app/models/door_mat/activity_reset_password.rb +47 -0
  28. data/app/models/door_mat/actor.rb +149 -0
  29. data/app/models/door_mat/change_password.rb +12 -0
  30. data/app/models/door_mat/email.rb +58 -0
  31. data/app/models/door_mat/forgot_password.rb +12 -0
  32. data/app/models/door_mat/membership.rb +42 -0
  33. data/app/models/door_mat/session.rb +315 -0
  34. data/app/models/door_mat/sign_in.rb +31 -0
  35. data/app/models/door_mat/sign_up.rb +17 -0
  36. data/app/views/door_mat/activity_mailer/confirm_email.html.erb +11 -0
  37. data/app/views/door_mat/activity_mailer/confirm_email.text.erb +7 -0
  38. data/app/views/door_mat/activity_mailer/reset_password.html.erb +11 -0
  39. data/app/views/door_mat/activity_mailer/reset_password.text.erb +7 -0
  40. data/app/views/door_mat/change_password/new.html.erb +22 -0
  41. data/app/views/door_mat/forgot_passwords/choose_new_password.html.erb +34 -0
  42. data/app/views/door_mat/forgot_passwords/new.html.erb +14 -0
  43. data/app/views/door_mat/helpers/_errors_if_any.html.erb +10 -0
  44. data/app/views/door_mat/manage_email/new.html.erb +14 -0
  45. data/app/views/door_mat/password_less_session/access_token.html.erb +16 -0
  46. data/app/views/door_mat/password_less_session/new.html.erb +34 -0
  47. data/app/views/door_mat/password_less_session_mailer/send_token.html.erb +11 -0
  48. data/app/views/door_mat/password_less_session_mailer/send_token.text.erb +7 -0
  49. data/app/views/door_mat/reconfirm_password/new.html.erb +12 -0
  50. data/app/views/door_mat/sign_in/new.html.erb +30 -0
  51. data/app/views/door_mat/sign_up/new.html.erb +24 -0
  52. data/app/views/door_mat/static/add_email_success.html.erb +5 -0
  53. data/app/views/door_mat/static/change_password_success.html.erb +2 -0
  54. data/app/views/door_mat/static/confirm_email_success.html.erb +2 -0
  55. data/app/views/door_mat/static/email_confirmation_required.html.erb +17 -0
  56. data/app/views/door_mat/static/forgot_password_verification_mail_sent.html.erb +2 -0
  57. data/app/views/door_mat/static/reconfirm_password_success.html.erb +4 -0
  58. data/app/views/door_mat/static/sign_in_success.html.erb +5 -0
  59. data/app/views/door_mat/static/sign_out_success.html.erb +5 -0
  60. data/app/views/door_mat/static/sign_up_success.html.erb +4 -0
  61. data/bin/rails +12 -0
  62. data/config/locales/en.yml +73 -0
  63. data/config/routes.rb +48 -0
  64. data/db/migrate/20140616234935_create_door_mat_actors.rb +23 -0
  65. data/db/migrate/20140617233357_create_door_mat_sessions.rb +17 -0
  66. data/db/migrate/20140630043202_create_door_mat_emails.rb +12 -0
  67. data/db/migrate/20140702045729_create_door_mat_activities.rb +14 -0
  68. data/db/migrate/20141115183045_create_door_mat_access_tokens.rb +17 -0
  69. data/db/migrate/20141121191824_create_door_mat_memberships.rb +14 -0
  70. data/db/migrate/20150910182126_rename_session_guid_column.rb +5 -0
  71. data/db/migrate/20150918210831_add_access_token_rating_column.rb +5 -0
  72. data/door_mat.gemspec +37 -0
  73. data/lib/door_mat.rb +20 -0
  74. data/lib/door_mat/attr_asymmetric_store.rb +82 -0
  75. data/lib/door_mat/attr_symmetric_store.rb +82 -0
  76. data/lib/door_mat/configuration.rb +193 -0
  77. data/lib/door_mat/controller.rb +117 -0
  78. data/lib/door_mat/crypto.rb +49 -0
  79. data/lib/door_mat/crypto/asymmetric_store.rb +77 -0
  80. data/lib/door_mat/crypto/fast_hash.rb +17 -0
  81. data/lib/door_mat/crypto/password_hash.rb +39 -0
  82. data/lib/door_mat/crypto/secure_compare.rb +23 -0
  83. data/lib/door_mat/crypto/symmetric_store.rb +68 -0
  84. data/lib/door_mat/engine.rb +23 -0
  85. data/lib/door_mat/process/actor_password_change.rb +65 -0
  86. data/lib/door_mat/process/actor_sign_in.rb +38 -0
  87. data/lib/door_mat/process/actor_sign_up.rb +39 -0
  88. data/lib/door_mat/process/create_new_anonymous_actor.rb +36 -0
  89. data/lib/door_mat/process/manage_email.rb +42 -0
  90. data/lib/door_mat/process/reset_password.rb +50 -0
  91. data/lib/door_mat/regex.rb +17 -0
  92. data/lib/door_mat/test_helper.rb +58 -0
  93. data/lib/door_mat/url_protocol.rb +9 -0
  94. data/lib/door_mat/version.rb +3 -0
  95. data/lib/tasks/door_mat_tasks.rake +31 -0
  96. data/spec/controllers/door_mat/activities_controller_spec.rb +70 -0
  97. data/spec/controllers/door_mat/forgot_passwords_controller_spec.rb +57 -0
  98. data/spec/controllers/door_mat/manage_email_spec.rb +181 -0
  99. data/spec/controllers/door_mat/password_less_session_controller_spec.rb +344 -0
  100. data/spec/controllers/door_mat/sign_in_controller_spec.rb +211 -0
  101. data/spec/controllers/door_mat/sign_up_controller_spec.rb +90 -0
  102. data/spec/factories/door_mat_access_tokens.rb +6 -0
  103. data/spec/factories/door_mat_activitiess.rb +6 -0
  104. data/spec/factories/door_mat_actors.rb +23 -0
  105. data/spec/factories/door_mat_emails.rb +14 -0
  106. data/spec/factories/door_mat_memberships.rb +6 -0
  107. data/spec/factories/door_mat_sessions.rb +24 -0
  108. data/spec/features/password_less_session_spec.rb +165 -0
  109. data/spec/features/remember_me_spec.rb +672 -0
  110. data/spec/features/session_spec.rb +336 -0
  111. data/spec/lib/attr_store_spec.rb +237 -0
  112. data/spec/lib/crypto_spec.rb +130 -0
  113. data/spec/lib/process_spec.rb +159 -0
  114. data/spec/models/door_mat/access_token_spec.rb +134 -0
  115. data/spec/models/door_mat/activity_spec.rb +38 -0
  116. data/spec/models/door_mat/actor_spec.rb +56 -0
  117. data/spec/models/door_mat/email_spec.rb +25 -0
  118. data/spec/models/door_mat/session_spec.rb +69 -0
  119. data/spec/spec_helper.rb +223 -0
  120. data/spec/support/timecop/timecop_helper.rb +52 -0
  121. data/spec/test_app/README.rdoc +28 -0
  122. data/spec/test_app/Rakefile +6 -0
  123. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  124. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  125. data/spec/test_app/app/controllers/account_controller.rb +28 -0
  126. data/spec/test_app/app/controllers/application_controller.rb +10 -0
  127. data/spec/test_app/app/controllers/password_less_sample_controller.rb +56 -0
  128. data/spec/test_app/app/controllers/static_controller.rb +7 -0
  129. data/spec/test_app/app/helpers/account_helper.rb +2 -0
  130. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  131. data/spec/test_app/app/models/game.rb +62 -0
  132. data/spec/test_app/app/models/shared_data.rb +4 -0
  133. data/spec/test_app/app/models/shared_key.rb +8 -0
  134. data/spec/test_app/app/models/user_detail.rb +7 -0
  135. data/spec/test_app/app/views/account/show.html.erb +133 -0
  136. data/spec/test_app/app/views/door_mat/static/sign_out_success.html.erb +7 -0
  137. data/spec/test_app/app/views/layouts/application.html.erb +20 -0
  138. data/spec/test_app/app/views/password_less_sample/draw_results.html.erb +6 -0
  139. data/spec/test_app/app/views/password_less_sample/final_result.html.erb +7 -0
  140. data/spec/test_app/app/views/password_less_sample/play_game.html.erb +5 -0
  141. data/spec/test_app/app/views/password_less_sample/show_loosing_door.html.erb +10 -0
  142. data/spec/test_app/app/views/static/index.html.erb +12 -0
  143. data/spec/test_app/app/views/static/only_confirmed_email_allowed.html.erb +10 -0
  144. data/spec/test_app/app/views/static/page_that_require_password_reconfirmation.html.erb +16 -0
  145. data/spec/test_app/app/views/static/session_protected_page.html.erb +32 -0
  146. data/spec/test_app/bin/bundle +3 -0
  147. data/spec/test_app/bin/rails +4 -0
  148. data/spec/test_app/bin/rake +4 -0
  149. data/spec/test_app/config.ru +4 -0
  150. data/spec/test_app/config/application.rb +29 -0
  151. data/spec/test_app/config/boot.rb +5 -0
  152. data/spec/test_app/config/database.yml +25 -0
  153. data/spec/test_app/config/environment.rb +19 -0
  154. data/spec/test_app/config/environments/development.rb +50 -0
  155. data/spec/test_app/config/environments/production.rb +83 -0
  156. data/spec/test_app/config/environments/test.rb +48 -0
  157. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  158. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  159. data/spec/test_app/config/initializers/door_mat.rb +72 -0
  160. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  161. data/spec/test_app/config/initializers/inflections.rb +16 -0
  162. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  163. data/spec/test_app/config/initializers/session_store.rb +3 -0
  164. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  165. data/spec/test_app/config/locales/en.yml +23 -0
  166. data/spec/test_app/config/routes.rb +42 -0
  167. data/spec/test_app/config/secrets.yml +31 -0
  168. data/spec/test_app/db/migrate/20140717182813_create_user_details.rb +10 -0
  169. data/spec/test_app/db/migrate/20140908225256_create_shared_data.rb +10 -0
  170. data/spec/test_app/db/migrate/20140908225604_create_shared_keys.rb +11 -0
  171. data/spec/test_app/db/migrate/20141121190714_create_games.rb +10 -0
  172. data/spec/test_app/public/404.html +67 -0
  173. data/spec/test_app/public/422.html +67 -0
  174. data/spec/test_app/public/500.html +66 -0
  175. data/spec/test_app/public/favicon.ico +0 -0
  176. metadata +552 -0
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,28 @@
1
+ class AccountController < ApplicationController
2
+ before_action -> {require_password_reconfirm(15)} # override the default password_reconfirm_delay
3
+ before_action :update_session_last_activity_time
4
+
5
+ def show
6
+ @actor = DoorMat::Session.current_session.actor
7
+
8
+ if @actor.user_detail.blank?
9
+ @actor.user_detail = UserDetail.new
10
+ end
11
+ end
12
+
13
+ def update
14
+ actor = DoorMat::Session.current_session.actor
15
+
16
+ actor.user_detail.name = update_params[:name]
17
+ actor.user_detail.save!
18
+
19
+ redirect_to account_show_url
20
+ end
21
+
22
+ private
23
+
24
+ def update_params
25
+ params.require(:user_detail).permit(:name)
26
+ end
27
+
28
+ end
@@ -0,0 +1,10 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ include DoorMat::Controller
7
+ before_action :require_valid_session
8
+ before_action :require_confirmed_email
9
+
10
+ end
@@ -0,0 +1,56 @@
1
+ class PasswordLessSampleController < ApplicationController
2
+
3
+ skip_before_action :require_valid_session
4
+ skip_before_action :require_confirmed_email
5
+ before_action -> {protected_by_password_less_session([:big_ticket, :multipass])}, only: [:draw_results, :play_game, :choose_door_post]
6
+ before_action -> {protected_by_password_less_session(:play_game)}, only: [:show_loosing_door, :final_choice_post]
7
+ before_action -> {protected_by_password_less_session(:show_loosing_door)}, only: [:final_result]
8
+ before_action :update_session_last_activity_time
9
+
10
+ def play_game
11
+ access_token = DoorMat::AccessToken.current_access_token
12
+
13
+ actor = DoorMat::Process::CreateNewAnonymousActor.owned_by(access_token.actor)
14
+ @game = Game.init_for_actor_and_doors(actor, 10)
15
+ @game.save!
16
+ access_token.reference_id = @game.id
17
+ access_token.save!
18
+
19
+ rescue Exception => e
20
+ DoorMat.configuration.logger.error "ERROR: Failed to save game? - #{e}"
21
+ end
22
+
23
+ def choose_door_post
24
+ access_token = DoorMat::AccessToken.current_access_token
25
+ @game = Game.find(access_token.reference_id)
26
+ @game.player_select_door! params[:door].to_i
27
+ @game.host_select_loosing_door
28
+ @game.save!
29
+
30
+ DoorMat::AccessToken.swap_token!(cookies, [:big_ticket, :multipass], :play_game)
31
+ redirect_to show_loosing_door_url
32
+ end
33
+
34
+ def show_loosing_door
35
+ access_token = DoorMat::AccessToken.current_access_token
36
+ @game = Game.find(access_token.reference_id)
37
+ end
38
+
39
+ def final_choice_post
40
+ access_token = DoorMat::AccessToken.current_access_token
41
+ @game = Game.find(access_token.reference_id)
42
+ @game.player_select_door! params[:door].to_i
43
+ @game.save!
44
+
45
+ DoorMat::AccessToken.swap_token!(cookies, :play_game, :show_loosing_door)
46
+ redirect_to final_result_url
47
+ end
48
+
49
+ def final_result
50
+ access_token = DoorMat::AccessToken.current_access_token
51
+ @game = Game.find(access_token.reference_id)
52
+
53
+ access_token.destroy!
54
+ end
55
+
56
+ end
@@ -0,0 +1,7 @@
1
+ class StaticController < ApplicationController
2
+ skip_before_action :require_valid_session, only: [:index]
3
+ skip_before_action :require_confirmed_email, only: [:index, :session_protected_page]
4
+
5
+ before_action :require_password_reconfirm, only: [:page_that_require_password_reconfirmation]
6
+ before_action :update_session_last_activity_time, only: [:session_protected_page]
7
+ end
@@ -0,0 +1,2 @@
1
+ module AccountHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,62 @@
1
+ class Game < ActiveRecord::Base
2
+ include DoorMat::AttrSymmetricStore
3
+
4
+ belongs_to :actor, class_name: 'DoorMat::Actor'
5
+
6
+ attr_symmetric_store :state
7
+
8
+ def self.init_for_actor_and_doors(actor, door_count)
9
+ game = Game.new
10
+ game.actor = actor
11
+ game.state = [
12
+ door_count, # doors
13
+ Array(1 .. door_count).sample, # winning door
14
+ 0, # player selected door
15
+ 0 # loosing door shown
16
+ ].join(':')
17
+ game
18
+ end
19
+
20
+ def number_of_doors
21
+ get_at(0)
22
+ end
23
+ def winning_door
24
+ get_at(1)
25
+ end
26
+ def player_selected_door
27
+ get_at(2)
28
+ end
29
+ def loosing_door_shown
30
+ get_at(3)
31
+ end
32
+
33
+ def player_select_door!(door_number)
34
+ raise "Invalid door number selected" unless ((door_number.to_i > 0) && (door_number.to_i <= number_of_doors))
35
+ set_at(2, door_number)
36
+ end
37
+
38
+ def host_select_loosing_door
39
+ return unless 0 == loosing_door_shown
40
+ available_doors = Array(1 .. number_of_doors)
41
+ available_doors.delete(winning_door)
42
+ available_doors.delete(player_selected_door)
43
+ set_at(3, available_doors.sample)
44
+ end
45
+
46
+ def player_win?
47
+ winning_door == player_selected_door
48
+ end
49
+
50
+ private
51
+
52
+ def get_at(i)
53
+ self.state.split(':')[i].to_i
54
+ end
55
+
56
+ def set_at(i, value)
57
+ state = self.state.split(':')
58
+ state[i] = value.to_s
59
+ self.state = state.join(':')
60
+ end
61
+
62
+ end
@@ -0,0 +1,4 @@
1
+ class SharedData < ActiveRecord::Base
2
+ has_many :shared_keys
3
+ has_many :actor, class_name: 'DoorMat::Actor', :through => :shared_keys
4
+ end
@@ -0,0 +1,8 @@
1
+ class SharedKey < ActiveRecord::Base
2
+ include DoorMat::AttrAsymmetricStore
3
+
4
+ belongs_to :actor, class_name: 'DoorMat::Actor'
5
+ belongs_to :shared_data
6
+
7
+ attr_asymmetric_store :key
8
+ end
@@ -0,0 +1,7 @@
1
+ class UserDetail < ActiveRecord::Base
2
+ include DoorMat::AttrSymmetricStore
3
+
4
+ belongs_to :actor, class_name: 'DoorMat::Actor'
5
+
6
+ attr_symmetric_store :name
7
+ end
@@ -0,0 +1,133 @@
1
+ <h1>Account#show</h1>
2
+ <p>Find me in app/views/account/show.html.erb</p>
3
+ <%= link_to 'Sign Out', door_mat.sign_out_path %><br>
4
+ <%= link_to 'Back to - Session protected page', main_app.session_protected_page_path %>
5
+
6
+ <h2>You are currently logged in as:</h2>
7
+ <%= DoorMat::Session.current_session.email.address %>
8
+
9
+ <h2>User Name</h2>
10
+ <%= form_for(@actor.user_detail, url: account_update_path) do |f| %>
11
+ <%= f.text_field :name %>
12
+ <%= f.submit 'Update' %>
13
+ <% end %>
14
+ <p>The UserDetail model demonstrate the automatic encryption of a text field using DoorMat::AttrSymmetricStore</p>
15
+
16
+
17
+ <h2>Recovery Key</h2>
18
+
19
+ <% download_recovery_key_activities = @actor.download_recovery_key_activities %>
20
+ <% if download_recovery_key_activities.blank? %>
21
+ <p>You have already downloaded your recovery key; to obtain a new one, change your password.</p>
22
+ <% else %>
23
+ <% if DoorMat::Session.current_session.private_computer?%>
24
+ <table>
25
+ <% @actor.download_recovery_key_activities.each do |key| %>
26
+ <tr>
27
+ <td>
28
+ Click below to download your recovery key.
29
+
30
+ <%= form_tag(door_mat.download_recovery_key_path) do %>
31
+ <%= hidden_field_tag( 'token', key.get_new_token) %>
32
+ <%= hidden_field_tag( 'disposition', 'attachment') %>
33
+ <%= submit_tag("Download") %>
34
+ <% end %>
35
+
36
+ </td>
37
+ </tr>
38
+ <% end %>
39
+ </table>
40
+ <% else %>
41
+ <p>Please sign in from a private computer in order to safely download your recovery key.</p>
42
+ <% end %>
43
+ <% end %>
44
+
45
+ <h2>Registered Email Address</h2>
46
+ <table>
47
+ <% @actor.emails.each do |email| %>
48
+ <tr>
49
+ <td>
50
+ <%= email.address %>
51
+ </td>
52
+ <td>
53
+ <% if email.confirmed? || email.primary? %>
54
+ Confirmed
55
+ <% else %>
56
+ <%= form_tag(door_mat.resend_email_confirmation_path) do %>
57
+ <%= hidden_field_tag( 'email', email.to_urlsafe_encoded) %>
58
+ <%= submit_tag("Resend confirmation email") %>
59
+ <% end %>
60
+ <% end %>
61
+ </td>
62
+
63
+ <% if email.primary? %>
64
+ <td>
65
+ Primary
66
+ </td>
67
+ <td>
68
+ Can't delete primary
69
+ </td>
70
+ <% else %>
71
+ <td>
72
+ <%= form_tag(door_mat.set_primary_email_path) do %>
73
+ <%= hidden_field_tag( 'email', email.to_urlsafe_encoded) %>
74
+ <%= submit_tag("Make primary") %>
75
+ <% end %>
76
+ </td>
77
+ <td>
78
+ <%= form_tag(door_mat.delete_email_path) do %>
79
+ <%= hidden_field_tag( 'email', email.to_urlsafe_encoded) %>
80
+ <%= submit_tag("Delete") %>
81
+ <% end %>
82
+ </td>
83
+ <% end %>
84
+ </tr>
85
+ <% end %>
86
+ </table>
87
+
88
+ <%= link_to 'Add new email', door_mat.add_email_path %>
89
+
90
+
91
+ <h2>Change Password</h2>
92
+ <%= link_to 'Change Password', door_mat.change_password_path %>
93
+
94
+ <h2>Active sessions</h2>
95
+ <table>
96
+ <% @actor.sessions.each do |session| %>
97
+ <% is_current_session = DoorMat::Session.current_session.hashed_token == session.hashed_token %>
98
+ <tr>
99
+ <td>
100
+ <% if is_current_session %>
101
+ *
102
+ <% end %>
103
+
104
+ <%= session.email.address %>
105
+ </td>
106
+ <td>
107
+ <%= session.hashed_token %>
108
+ </td>
109
+ <td>
110
+ <%= session.ip %>
111
+ </td>
112
+ <td>
113
+ <%= session.created_at %>
114
+ </td>
115
+ <td>
116
+ <%= session.updated_at %>
117
+ </td>
118
+ <td>
119
+ <%= session.password_authenticated_at %>
120
+ </td>
121
+ <td>
122
+ <% unless is_current_session %>
123
+ <%= button_to "Terminate", door_mat.terminate_session_path(session.hashed_token), method: :post%>
124
+ <% end %>
125
+ </td>
126
+ </tr>
127
+ <tr>
128
+ <td colspan="4">
129
+ <%= session.agent %>
130
+ </td>
131
+ </tr>
132
+ <% end %>
133
+ </table>
@@ -0,0 +1,7 @@
1
+ <h1>You have successfully signed out!</h1>
2
+
3
+ <p>Find me in test_app/app/views/door_mat/static/sign_out_success.html.erb</p>
4
+
5
+ <p>This page is a static placeholder for the DoorMat test app. It overrides the default app/views/door_mat/static/sign_out_success.html.erb</p>
6
+
7
+ <%= link_to 'Sign In', door_mat.sign_in_path %>
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>TestApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <% flash.each do |type, message| %>
12
+ <div class="<%= type %>">
13
+ <%= message %>
14
+ </div>
15
+ <% end %>
16
+
17
+ <%= yield %>
18
+
19
+ </body>
20
+ </html>
@@ -0,0 +1,6 @@
1
+
2
+ <p>Big ticket Winner!</p>
3
+
4
+ <p>
5
+ Would you like to <%= link_to 'Play a game?', play_game_url %>
6
+ </p>
@@ -0,0 +1,7 @@
1
+ <% if @game.player_win? %>
2
+ <p>You win!</p>
3
+ <% else %>
4
+ <p>You lose!</p>
5
+ <% end %>
6
+
7
+ <p>Door <%= @game.winning_door %> was the winning door!</p>
@@ -0,0 +1,5 @@
1
+ <p>Choose a door</p>
2
+ <%= form_tag(choose_door_path) do %>
3
+ <%= select_tag "door", options_for_select(Array(1 .. @game.number_of_doors.to_i).map {|n| [n.to_s, n]}) %>
4
+ <%= submit_tag "Next" %>
5
+ <% end %>
@@ -0,0 +1,10 @@
1
+
2
+ <p>The host now opens a losing door:</p>
3
+ <p>Door <%= @game.loosing_door_shown %> is a losing door!</p>
4
+
5
+ <p>You can change your selection</p>
6
+ <p>Please submit your final decision:</p>
7
+ <%= form_tag(final_choice_path) do %>
8
+ <%= select_tag "door", options_for_select(Array(1 .. @game.number_of_doors.to_i).map {|n| [n.to_s, n]}, @game.player_selected_door) %>
9
+ <%= submit_tag "Next" %>
10
+ <% end %>
@@ -0,0 +1,12 @@
1
+
2
+ <p>This is a sample application using the DoorMat engine to manage and secure user accounts</p>
3
+
4
+ <h2>Password protected site</h2>
5
+ <%= link_to 'Sign In', door_mat.sign_in_path %>
6
+ <p>
7
+ Don't have an account yet? <%= link_to 'Sign Up', door_mat.sign_up_path %>
8
+ </p>
9
+
10
+
11
+ <h2>Password less, access token protected site</h2>
12
+ <%= link_to 'Would you like to play a game?', main_app.draw_results_path %>