rails-automaticlogout 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rspec +2 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +99 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +7 -0
- data/README.md +4 -1
- data/app/assets/javascripts/automatic_logout.js +29 -27
- data/app/views/automatic_logout/_timer.html.erb +1 -0
- data/lib/rails/automaticlogout/controllers/helpers.rb +19 -5
- data/lib/rails/automaticlogout/version.rb +1 -1
- data/rails-automaticlogout.gemspec +5 -3
- metadata +27 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 886bac714ec7c95fef68f92b348d4efaa3c6a81c
|
4
|
+
data.tar.gz: 926892faf3a86b51ee29e46f98065019b4e9fd96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5132ad23ef7b9f2836765ff32c2eed36abdff1bcd1c9be911a1c8c1e0b1291ccd7b9acd0effa5179c45efb762609bcd442fc1e6d112d8e190a83c0fc2c851776
|
7
|
+
data.tar.gz: 96a56ccee0dd739254710d14f79d539bf2641c6a42274a6d07b24796dad01b082616803f67fdc48303b0fd3b2696b9faf92208ff0e8f0307ece53c5fa7ef19b6
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
We love pull requests from everyone. By participating in this project, you're encouraged to submit [pull requests](https://github.com/Thadeu/rails-automaticlogout/pulls), [propose features and discuss issues](https://github.com/Thadeu/rails-automaticlogout/issues). When in doubt, ask a question using issues.
|
4
|
+
|
5
|
+
#### Fork the Project
|
6
|
+
|
7
|
+
Fork the [project on Github](https://github.com/Thadeu/rails-automaticlogout) and check out your copy.
|
8
|
+
|
9
|
+
```
|
10
|
+
git clone https://github.com/contributor/rails-automaticlogout.git
|
11
|
+
cd rails-automaticlogout
|
12
|
+
git remote add upstream https://github.com/Thadeu/rails-automaticlogout.git
|
13
|
+
```
|
14
|
+
|
15
|
+
#### Create a Topic Branch
|
16
|
+
|
17
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
18
|
+
|
19
|
+
```
|
20
|
+
git checkout master
|
21
|
+
git pull upstream master
|
22
|
+
git checkout -b my-feature-branch
|
23
|
+
```
|
24
|
+
#### Write Tests
|
25
|
+
|
26
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
27
|
+
|
28
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
29
|
+
|
30
|
+
#### Write Documentation
|
31
|
+
|
32
|
+
Document any external behavior in the [README](README.md).
|
33
|
+
|
34
|
+
#### Update Changelog
|
35
|
+
|
36
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Unreleased*. Make it look like every other line, including your name and link to your Github account.
|
37
|
+
|
38
|
+
#### Commit Changes
|
39
|
+
|
40
|
+
Make sure git knows your name and email address:
|
41
|
+
|
42
|
+
```
|
43
|
+
git config --global user.name "Your Name"
|
44
|
+
git config --global user.email "contributor@example.com"
|
45
|
+
```
|
46
|
+
|
47
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
48
|
+
|
49
|
+
```
|
50
|
+
git add ...
|
51
|
+
git commit
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Push
|
55
|
+
|
56
|
+
```
|
57
|
+
git push origin my-feature-branch
|
58
|
+
```
|
59
|
+
|
60
|
+
#### Make a Pull Request
|
61
|
+
|
62
|
+
Go to https://github.com/contributor/rails-automaticlogout and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
63
|
+
|
64
|
+
#### Rebase
|
65
|
+
|
66
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
67
|
+
|
68
|
+
```
|
69
|
+
git fetch upstream
|
70
|
+
git rebase upstream/master
|
71
|
+
git push origin my-feature-branch -f
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Update CHANGELOG Again
|
75
|
+
|
76
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
77
|
+
|
78
|
+
```
|
79
|
+
* [#123](https://github.com/Thadeu/rails-automaticlogout/pull/1): New Feature x - [@contributor](https://github.com/contributor).
|
80
|
+
```
|
81
|
+
|
82
|
+
Amend your previous commit and force push the changes.
|
83
|
+
|
84
|
+
```
|
85
|
+
git commit --amend
|
86
|
+
git push origin my-feature-branch -f
|
87
|
+
```
|
88
|
+
|
89
|
+
#### Check on Your Pull Request
|
90
|
+
|
91
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
92
|
+
|
93
|
+
#### Be Patient
|
94
|
+
|
95
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
96
|
+
|
97
|
+
#### Thank You
|
98
|
+
|
99
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2016-2017 Thadeu Esteves Jr. https://github.com/Thadeu/rails-automaticlogout/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -62,7 +62,7 @@ end
|
|
62
62
|
### Configure Javascript
|
63
63
|
Add in your application.js this require
|
64
64
|
|
65
|
-
```javascript
|
65
|
+
```javascript
|
66
66
|
//= require automatic_logout
|
67
67
|
```
|
68
68
|
### Configure View (OPTIONAL)
|
@@ -77,6 +77,9 @@ Use Helper in your view, for show regressive timer. Add this in your file applic
|
|
77
77
|
* Add translations
|
78
78
|
* Add configurations for action_view
|
79
79
|
* Add Suport for Rails 5.x
|
80
|
+
* Setup test environment
|
81
|
+
* Add Tests
|
82
|
+
* Integrate automatic verification services (Travis-CI, Hakiri, CodeClimate, etc)
|
80
83
|
|
81
84
|
|
82
85
|
## Contributing
|
@@ -34,35 +34,37 @@ AutomaticLogout.regressiveTimer = function(){;
|
|
34
34
|
*/
|
35
35
|
var data_timer = $('.regressive-timer').data('expires-at'),
|
36
36
|
data_message = $('.regressive-timer').data('message'),
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
37
|
+
data_seconds = $('.regressive-timer').data('seconds'),
|
38
|
+
current_time = new Date().getTime();
|
39
|
+
|
40
|
+
var time_expired = new Date();
|
41
|
+
time_expired.setSeconds(time_expired.getSeconds() + data_seconds);
|
42
|
+
|
43
|
+
var timerDecrement = setInterval(function(){
|
44
|
+
|
45
|
+
if (data_seconds == 0) {
|
46
|
+
clearInterval(timerDecrement);
|
47
|
+
|
48
|
+
// limpa a sessão após o ok
|
49
|
+
alertify.alert(data_message, function () {
|
50
|
+
AutomaticLogout.destroySession();
|
51
|
+
});
|
52
|
+
}else{
|
53
|
+
//tempo descrecente
|
54
|
+
time_expired.setSeconds(time_expired.getSeconds() - 1);
|
55
|
+
|
56
|
+
var
|
57
|
+
// converte pra segundos
|
58
|
+
seconds_integer = (time_expired.getTime() - current_time) / 1000,
|
59
|
+
//faz o parse
|
60
|
+
date_format = AutomaticLogout.parseDate(seconds_integer);
|
61
|
+
|
62
|
+
// atualiza o DOM
|
59
63
|
$('.regressive-timer').text(date_format.hours + ':' + date_format.minutes + ':' + date_format.seconds);
|
60
64
|
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
diff_in_seconds--;
|
65
|
-
}
|
65
|
+
|
66
|
+
data_seconds -= 1;
|
67
|
+
}, 1000)
|
66
68
|
}
|
67
69
|
|
68
70
|
/**
|
@@ -1,20 +1,34 @@
|
|
1
1
|
module Rails::AutomaticLogout
|
2
2
|
module Controllers
|
3
3
|
module Helpers
|
4
|
-
|
5
|
-
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_time
|
10
|
+
Time.now
|
11
|
+
end
|
12
|
+
|
13
|
+
def expires_at(time)
|
14
|
+
current_time + time
|
15
|
+
end
|
16
|
+
|
17
|
+
def expires_at_in_seconds(time)
|
18
|
+
# ((current_time + time)).strftime("%s").to_i
|
19
|
+
time.seconds.to_i
|
6
20
|
end
|
7
21
|
|
8
22
|
module ClassMethods
|
9
23
|
def automatic_logout_at(time: 1.hour, message: "Session expired! You will be redirect.")
|
10
24
|
prepend_before_filter do |c|
|
11
|
-
if c.session[:auto_session_expires_at].present? && c.session[:auto_session_expires_at] <
|
25
|
+
if c.session[:auto_session_expires_at].present? && c.session[:auto_session_expires_at] < current_time
|
12
26
|
c.send :reset_session
|
13
27
|
else
|
14
28
|
if current_user
|
15
|
-
c.session[:auto_session_expires_at] =
|
29
|
+
c.session[:auto_session_expires_at] = expires_at(time)
|
30
|
+
c.session[:seconds] = expires_at_in_seconds(time)
|
16
31
|
c.session[:message] = message
|
17
|
-
c.session[:seconds] = time.seconds
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "
|
22
|
-
spec.add_development_dependency "
|
23
|
-
spec.add_development_dependency "
|
21
|
+
spec.add_development_dependency "rails", "~> 4.2"
|
22
|
+
spec.add_development_dependency "factory_girl_rails"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
24
|
+
spec.add_development_dependency 'rspec-rails'
|
25
|
+
|
24
26
|
spec.add_dependency "alertify-rails", "~> 0.2.0"
|
25
27
|
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-automaticlogout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thadeu Esteves Jr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: factory_girl_rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,19 +39,33 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.11'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: alertify-rails
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,7 +88,11 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- CHANGELOG.md
|
93
|
+
- CONTRIBUTING.md
|
77
94
|
- Gemfile
|
95
|
+
- LICENSE.txt
|
78
96
|
- README.md
|
79
97
|
- Rakefile
|
80
98
|
- app/assets/javascripts/automatic_logout.js
|