session_timeout_prompter 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 6be9fd633cab048831eaf8e2a706ef4dc8f87620
4
- data.tar.gz: 11c086142b91fb883a39d4fdd3b7a81a26ea3a1b
3
+ metadata.gz: 8c7fbaf882ad6d1a5a7db7e458d261f10d99727a
4
+ data.tar.gz: 338e1df2e8fe1d5771e332bab2811aff96c08e06
5
5
  SHA512:
6
- metadata.gz: 72d21ca10cd794f5d5b9001692a28e96a4e251cb7d54ecba662f67d51d915aa22574f02b9447f22006dbbeff907a0c0e13e86c5ce8735e614d77ee9e4bbacb8e
7
- data.tar.gz: 16d1882386159825f8c1e41465ef3b45ab8c9c3ffe6804ccea53e56d8531d70cf3d9dc596e78a24859ce14ac5803c7f1e0fb6b12d6ca006924821d4d6c85ccef
6
+ metadata.gz: a9f5905795425218208f886f1351727dbd04144f3079858cb032f50adf35baecc919558caa38b677b1f9e5399a4b60531bb21cce02301dfe8f57550a0580091a
7
+ data.tar.gz: f9b973def95f829b61592cc3549fc5ba768fd8347dd0c89c9211f384cf065a2f88f1d9e338014bd05ea1796d2001a4fcd4a75d8ec1e3a68257f8831422d36e2b
data/README.md CHANGED
@@ -10,10 +10,16 @@ Add the gem to your Gemfile:
10
10
  gem 'session_timeout_prompter'
11
11
  ```
12
12
 
13
+ Run bundle install
14
+
15
+ ```ruby
16
+ bundle install
17
+ ```
18
+
13
19
  Mount the engine in your routes:
14
20
 
15
21
  ```ruby
16
- mount SessionTimeoutPrompter::Engine at: "/session_timeout_prompter"`
22
+ mount SessionTimeoutPrompter::Engine, at: "/session_timeout_prompter"
17
23
  ```
18
24
 
19
25
  Require the js:
@@ -35,7 +41,7 @@ Require the css:
35
41
  Add the following after the body tag in your layout or on any page you wish to display the timeout prompt:
36
42
 
37
43
  ```ruby
38
- = session_timeout_prompter(session_timeout_in_seconds: User.timeout_in.to_i, timeout_warning_in_seconds: 305, scope: :user)
44
+ = init_session_timeout_prompter(session_timeout_in_seconds: User.timeout_in.to_i, seconds_to_warn_before_timeout: 305, scope: :user)
39
45
  ```
40
46
  (The example values assume you are using Devise timeoutable and are using a scope/model called User. The scope is purely so you can use multiple in the same application if necessary.)
41
47
 
@@ -41,6 +41,7 @@ var Bootstrap3PromptRenderer = (function () {
41
41
  value: function hideAll() {
42
42
  this.timeoutWarningModal.modal('hide');
43
43
  this.timedOutModal.modal('hide');
44
+ this.currentlyShowingWarningPrompt = false;
44
45
  }
45
46
  }, {
46
47
  key: 'updateRemainingTimeText',
@@ -104,6 +105,20 @@ var ServerPinger = (function () {
104
105
  })();
105
106
  'use strict';
106
107
 
108
+ var sessionTimeoutPrompter = undefined;
109
+ jQuery(function () {
110
+
111
+ var timeoutPrompterContainer = jQuery('#session-timeout-prompter-container');
112
+
113
+ // If the container cannot be found then assume we don't need timeout prompting on this page.
114
+ if (timeoutPrompterContainer.length) {
115
+ var configData = timeoutPrompterContainer.data();
116
+ sessionTimeoutPrompter = new SessionTimeoutPrompter(configData);
117
+ sessionTimeoutPrompter.start();
118
+ }
119
+ });
120
+ 'use strict';
121
+
107
122
  var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
108
123
 
109
124
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
@@ -113,7 +128,7 @@ var SessionTimeoutPrompter = (function () {
113
128
  _classCallCheck(this, SessionTimeoutPrompter);
114
129
 
115
130
  var serverPingPath = configData.serverPingPath;
116
- var timeoutWarningInSeconds = configData.timeoutWarningInSeconds;
131
+ var secondsToWarnBeforeTimeout = configData.secondsToWarnBeforeTimeout;
117
132
  var sessionTimeoutInSeconds = configData.sessionTimeoutInSeconds;
118
133
  var sessionKey = configData.sessionKey;
119
134
 
@@ -123,7 +138,7 @@ var SessionTimeoutPrompter = (function () {
123
138
 
124
139
  var promptRenderer = new Bootstrap3PromptRenderer(timeoutWarningModal, timedOutModal, remainingTimeContainer);
125
140
 
126
- this.timeoutTimer = new TimeoutTimer(timeoutWarningInSeconds, sessionTimeoutInSeconds, sessionKey, promptRenderer);
141
+ this.timeoutTimer = new TimeoutTimer(secondsToWarnBeforeTimeout, sessionTimeoutInSeconds, sessionKey, promptRenderer);
127
142
  this.serverPinger = new ServerPinger(serverPingPath);
128
143
  this.remainLoggedInButton = jQuery('#session-timeout-prompter-remain-logged-in-btn');
129
144
  }
@@ -167,20 +182,6 @@ var SessionTimeoutPrompter = (function () {
167
182
 
168
183
  return SessionTimeoutPrompter;
169
184
  })();
170
- 'use strict';
171
-
172
- var sessionTimeoutPrompter = undefined;
173
- jQuery(function () {
174
-
175
- var timeoutPrompterContainer = jQuery('#session-timeout-prompter-container');
176
-
177
- // If the container cannot be found then assume we don't need timeout prompting on this page.
178
- if (timeoutPrompterContainer.length) {
179
- var configData = timeoutPrompterContainer.data();
180
- sessionTimeoutPrompter = new SessionTimeoutPrompter(configData);
181
- sessionTimeoutPrompter.start();
182
- }
183
- });
184
185
  "use strict";
185
186
 
186
187
  var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
@@ -189,18 +190,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
189
190
 
190
191
  var TimeoutTimer = (function () {
191
192
 
192
- // timeoutWarningInSeconds: Warning that their session is about to timeout
193
+ // secondsToWarnBeforeTimeout: Warning that their session is about to timeout
193
194
  // when there are this many minutes left.
194
195
  // sessionTimeoutInSeconds: Tell them their session has timed out when this
195
196
  // many minutes have elapsed.
196
197
  // sessionKey: Unique key for this session - used in local storage
197
198
  // to make sure multiple browser tabs are synched.
198
199
 
199
- function TimeoutTimer(timeoutWarningInSeconds, sessionTimeoutInSeconds, sessionKey, promptRenderer) {
200
+ function TimeoutTimer(secondsToWarnBeforeTimeout, sessionTimeoutInSeconds, sessionKey, promptRenderer) {
200
201
  _classCallCheck(this, TimeoutTimer);
201
202
 
202
203
  this.sessionTimeoutInSeconds = sessionTimeoutInSeconds;
203
- this.timeoutWarningInSeconds = timeoutWarningInSeconds;
204
+ this.secondsToWarnBeforeTimeout = secondsToWarnBeforeTimeout;
204
205
  this.sessionKey = sessionKey;
205
206
  this.promptRenderer = promptRenderer;
206
207
  this.tickInterval = undefined;
@@ -248,7 +249,7 @@ var TimeoutTimer = (function () {
248
249
  var timeLeftInSeconds = this.timeoutAt - this.currentTimestamp();
249
250
  if (timeLeftInSeconds <= 0) {
250
251
  this.showTimedOutPrompt();
251
- } else if (timeLeftInSeconds <= this.timeoutWarningInSeconds) {
252
+ } else if (timeLeftInSeconds <= this.secondsToWarnBeforeTimeout) {
252
253
  this.showTimeoutWarningPrompt(timeLeftInSeconds);
253
254
  }
254
255
  }
@@ -4,19 +4,19 @@ module SessionTimeoutPrompter
4
4
  # session_timeout_in_seconds: The session timeout length set for your app
5
5
  # (most often from User.timeout_in.to_i if using Devise)
6
6
  #
7
- # timeout_warning_in_seconds: Show a warning this many seconds before the session times out.
7
+ # seconds_to_warn_before_timeout: Show a warning this many seconds before the session times out.
8
8
  #
9
9
  # scope: e.g. :user - most often the name of the Devise scope/model
10
10
  #
11
11
  # session_key: Unique key for this app and scope - used to enable multi-tab support
12
- def init_session_timeout_prompter(session_timeout_in_seconds:, timeout_warning_in_seconds:, scope:)
12
+ def init_session_timeout_prompter(session_timeout_in_seconds:, seconds_to_warn_before_timeout:, scope:)
13
13
  render(
14
14
  partial: "session_timeout_prompter/modal_dialogs",
15
15
  locals: {
16
16
  container_data_attributes: {
17
17
  server_ping_path: session_timeout_prompter.server_pings_path,
18
18
  session_timeout_in_seconds: session_timeout_in_seconds,
19
- timeout_warning_in_seconds: timeout_warning_in_seconds,
19
+ seconds_to_warn_before_timeout: seconds_to_warn_before_timeout,
20
20
  session_key: "#{::Rails.application.class.parent_name.downcase}-#{scope}"
21
21
  }
22
22
  }
@@ -1,3 +1,3 @@
1
1
  module SessionTimeoutPrompter
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency 'sqlite3'
39
39
  spec.add_development_dependency "jasmine"
40
40
  spec.add_development_dependency "babel-transpiler"
41
+ spec.add_development_dependency "phantomjs"
41
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: session_timeout_prompter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ant Nettleship
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-04 00:00:00.000000000 Z
11
+ date: 2017-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: phantomjs
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
251
265
  description:
252
266
  email:
253
267
  - anthony.nettleship@epigenesys.org.uk