devise-automaticlogout 1.0.0 → 1.0.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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7376a12b6138d60c5313dff7b3920fd377680f4158600517f73ae3697d7d08c9
4
- data.tar.gz: 252322e067196b1ec2d6ed3d2972a51a510251ab9af83efa380fdf39524e25a8
3
+ metadata.gz: c65ca7bde577d272a4d8ed64fe207d9e1fe383bc3a650d6692b2241a041c9617
4
+ data.tar.gz: 1f9de9666f2c64ef38406951191b1a462e089f92d66a59370c4ec2cc92ae48df
5
5
  SHA512:
6
- metadata.gz: f291157a5b46de703a70cf80cd5c231a9c918bb8652f5c2ac77cd6c9a7bbbc13d0157361900946a74dbdf7da0d51bd14f5e67db21620d54e4101dc4ca7f44249
7
- data.tar.gz: 6baba66024afd9be78928af7bcb99ffe7b7c8b7bf536b5d3b14c18cc37b85427096d290546166be2bb05a354bcb8f90b4954881dcde6304bf29a30e746130cdd
6
+ metadata.gz: 2f1aef7607fe60b6decb7d79b51ce226bfaf5b750d340cdf5ddde2abe05c280866c42ce4e629212302ae144fa4dcc3d5a1ab93c628ea9f69751e7eb36ca6dbe7
7
+ data.tar.gz: 59314f10e3fc2264a0c6688cba8e58319a0e283c076e7c112a96a357affd253954dae99c2e42dcfef8c80da1dd4be71380f00f0bce87ebf9d3f741a673eddd91
data/README.md CHANGED
@@ -1,47 +1,128 @@
1
1
  # Devise Automatic Logout
2
+
2
3
  By Thadeu Esteves Jr.
3
4
 
4
- Provides automatic session timeout in a Rails application. Very easy to install and configure. Have you ever wanted to force your users off your app if they go idle for a certain period of time? Many online banking sites use this technique. If your app is used on any kind of public computer system, this plugin is a necessity.
5
+ Provê um logout automático da sessão numa aplicação Rails utilizando Devise. É simples e fácil.
6
+ Faz com que a sessão seja destruída após a conclusão do tempo estipulado. É de grande ajuda em sistemas que necessitam de sessão auto destrutiva, evitando de o usuário ficar logado por muito tempo de forma ociosa.
7
+
8
+ ## O que isso faz?
9
+
10
+ * Força o usuário a sair da sessão (logout)
11
+ * Opção de mostrar um timer regressivo
12
+ * Opção de dar um alerta na tela ao ser deslogado
13
+
14
+ ## Começando
15
+
16
+ Adicione ao seu Gemfile
17
+
18
+ ```ruby
19
+ gem 'devise-automaticlogout', '~> 1.0'
20
+ ```
21
+
22
+ Rode o `bundle install`
23
+
24
+ ## Configure o controller
25
+
26
+ No controller que você deseja aplicar o timer para o devise, use:
27
+
28
+ ```ruby
29
+ devise_automatic_logout
30
+ ```
31
+
32
+ Por exemplo, para o comum ApplicationController, poderia ser
33
+
34
+ ```ruby
35
+ class ApplicationController < ActionController::Base
36
+ devise_automatic_logout
37
+ end
38
+ ```
39
+
40
+ Isso por si só, já prepara a aplicação para ler os dados do `Devise#timeout_in`, utilizando o scope padrão `user` e uma mensagem padrão de alerta.
41
+
42
+ Mas se você quiser, configurar um tempo diferente do timeout_in do devise? Fácil, use o seguinte:
43
+
44
+ ```ruby
45
+ devise_automatic_logout time: 1.hour.to_i
46
+ ```
47
+
48
+ Isso vai aplicar 1 hora para o logout automático.
49
+
50
+ Mas e se você quiser colocar outra mensagem? Fácil, use o seguinte:
51
+
52
+ ```ruby
53
+ devise_automatic_logout time: 1.hour.to_i, message: 'SUA MENSAGEM'
54
+ ```
5
55
 
6
- * Force your users power off session
7
- * show for they the regressive time
56
+ Mas e se você quiser fazer, com que seja utilizado outro tipo de mapping do devise? Fácil, use o seguinte:
8
57
 
9
- ## Getting started
58
+ ```ruby
59
+ devise_automatic_logout scope: 'member'
60
+ ```
10
61
 
11
- You can add it to your Gemfile with:
62
+ É possível também utilizar todos de uma vez só, por exemplo
12
63
 
13
64
  ```ruby
14
- gem 'devise-automaticlogout'
65
+ devise_automatic_logout time: 15.minutes.to_i, message: 'Sua sessão expirou! Faça login novamente.', scope: 'member'
15
66
  ```
16
67
 
17
- Then run bundle install
68
+ __OBS: Quando o `time` não é passado, o timeout_in do devise será aplicado, se configurado, é claro!__
18
69
 
19
- ## How to use?
70
+ ## Configurando Timeoutable
20
71
 
21
- ## Configure Timeoutable in /config/initializers/devise.rb
72
+ Veja na documentação do próprio devise como fazer isso.
22
73
 
23
- Besides :stretches, you can define :pepper, :encryptor, :confirm_within, :remember_for, :timeout_in, :unlock_in among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at /config/initializers/devise.rb.
74
+ [Configurar o tempo](https://github.com/plataformatec/devise#configuring-models)
24
75
 
25
- [Configure time](https://github.com/plataformatec/devise#configuring-models)
76
+ [Mais informações sobre Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable)
26
77
 
27
- [More informations](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable)
78
+ ## Configurando o timer regressivo (OBRIGATÓRIO)
28
79
 
29
- ### Configure Javascript
30
- Add in your application.js this require
80
+ Esse helper deve ser usado em qualquer view, ele é importante, pois tudo será baseado nele
81
+
82
+ ```ruby
83
+ <%= regressive_timer visible: true, alert: true %>
84
+ ```
85
+
86
+ * visible: mostra um timer regressivo
87
+ * alert: lança um `window.alert` se ativado, ao final do timer
88
+
89
+ ## Configurando Javascript
90
+
91
+ Adicione no seu application.js, o seguinte:
31
92
 
32
93
  ```javascript
33
94
  //= require automatic_logout
34
95
  ```
35
- ### Configure View (OPTIONAL)
36
96
 
37
- Use Helper in your view, for show regressive timer. Add this in your file application.html.erb
97
+ Se você usa vanilla js, adicionar também o seguinte:
38
98
 
39
- ```ruby
40
- <%= regressive_timer %>
99
+ ```javascript
100
+ //= require automatic_logout/classic
101
+ ```
102
+
103
+ Se você usa jQuery, use:
104
+
105
+ ```javascript
106
+ //= require automatic_logout/jquery
107
+ ```
108
+
109
+ Se você usa Turbolinks mais atual, use:
110
+
111
+ ```javascript
112
+ //= require automatic_logout/turbolinks
41
113
  ```
42
114
 
43
- ## TODO
115
+ Se você usa Turbolinks mais antigo, use:
44
116
 
117
+ ```javascript
118
+ //= require automatic_logout/turbolinks-classic
119
+ ```
120
+
121
+ Se preferir, use manualmente em algum momento desejado
122
+
123
+ ```javascript
124
+ AutomaticLogout.load();
125
+ ```
45
126
 
46
127
  ## Contributing
47
128
 
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Automaticlogout
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-automaticlogout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thadeu Esteves Jr