tkh_authentication 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/README.md +11 -5
- data/app/controllers/users_controller.rb +1 -1
- data/lib/generators/tkh_authentication/install/install_generator.rb +0 -2
- data/lib/generators/tkh_authentication/install/templates/locales/en.yml +2 -1
- data/lib/generators/tkh_authentication/install/templates/locales/es.yml +2 -1
- data/lib/generators/tkh_authentication/install/templates/locales/fr.yml +1 -0
- data/lib/generators/tkh_authentication/update_locales/update_locales_generator.rb +18 -0
- data/lib/tkh_authentication/tkh_authentication_action_controller_extension.rb +4 -0
- data/lib/tkh_authentication/version.rb +1 -1
- metadata +5 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,10 @@ You need a root route in your app but most apps have that already.
|
|
29
29
|
And then of course restart your server!
|
30
30
|
|
31
31
|
$ rails s
|
32
|
+
|
33
|
+
Upon upgrading to a new version of the gem you might have to update the translation files
|
34
|
+
|
35
|
+
$ rails g tkh_authentication:update_locales -f
|
32
36
|
|
33
37
|
|
34
38
|
## Usage
|
@@ -42,13 +46,15 @@ A starting point could be:
|
|
42
46
|
|
43
47
|
To display the login information module anywhere in your views
|
44
48
|
|
45
|
-
|
49
|
+
render 'shared/login_info'
|
50
|
+
|
51
|
+
At this point the user only needs to be authenticated to access any area. We are coming up with an authorization solution as well. To restrict access to your controllers:
|
52
|
+
|
53
|
+
before_filter :authenticate
|
46
54
|
|
47
|
-
|
55
|
+
If you want to restrict access to users whose admin boolean attribute is true
|
48
56
|
|
49
|
-
|
50
|
-
before_filter :authenticate, :only => [ 'new', 'edit']
|
51
|
-
before_filter :authenticate, :except => 'show'
|
57
|
+
before_filter :authenticate_with_admin
|
52
58
|
|
53
59
|
|
54
60
|
## Contributing
|
@@ -22,8 +22,6 @@ module TkhAuthentication
|
|
22
22
|
|
23
23
|
def copy_locales
|
24
24
|
puts 'creating locale files'
|
25
|
-
# copy_file "locales/en.yml", "config/locales/tkh_authentication.en.yml"
|
26
|
-
# copy_file "locales/fr.yml", "config/locales/tkh_authentication.fr.yml"
|
27
25
|
I18n.available_locales.each do |l|
|
28
26
|
copy_file "locales/#{l.to_s}.yml", "config/locales/tkh_authentication.#{l.to_s}.yml"
|
29
27
|
end
|
@@ -32,7 +32,8 @@ en:
|
|
32
32
|
email_or_password_invalid: "Email or password is invalid"
|
33
33
|
login_needed: "You must be logged in to access this page. You have been redirected to the login form."
|
34
34
|
no_such_email: "We do not have any accounts with the email you have provided."
|
35
|
-
password_reset_expired: "Password reset has expired. There was a 24 hours grace period"
|
35
|
+
password_reset_expired: "Password reset has expired. There was a 24 hours grace period"
|
36
|
+
restricted_access: "This section is reserved to the site's administrators. Contact the site owner if you would like access to be granted to you."
|
36
37
|
|
37
38
|
|
38
39
|
# leaving these until I have used up all the ones I need.
|
@@ -29,4 +29,5 @@ es:
|
|
29
29
|
email_or_password_invalid: 'Correo electrónico o contraseña no válidos'
|
30
30
|
login_needed: 'Tienes que estar conectado para acceder a esta pagina. Te redirijimos al formulario para conectar.'
|
31
31
|
no_such_email: 'No existe ninguna cuenta con el correo electronico que nos has proporcionado.'
|
32
|
-
password_reset_expired: 'El reestablecimiento de la contraseña ha caducado. Tienes 24 horas para intentarlo otra vez.'
|
32
|
+
password_reset_expired: 'El reestablecimiento de la contraseña ha caducado. Tienes 24 horas para intentarlo otra vez.'
|
33
|
+
restricted_access: "Esta parte del sitio está reservado para los administradores. Por favor, pedir permiso al propietario del sitio."
|
@@ -198,6 +198,7 @@ fr:
|
|
198
198
|
login_needed: "Vous devez vous identifier pour accéder cette page. Vous avez été rediirigé à la page d'identification."
|
199
199
|
no_such_email: "Désolé nous n'avons pas d'utilisateur avec cette adresse email"
|
200
200
|
password_reset_expired: "Votre mot de passe n'a pu être réinitialisé car votre demande date de plus de 24 heures."
|
201
|
+
restricted_access: "Cette partie du site est réservée aux administrateurs. Veuillez demander l'autorisation au propriétaire du site."
|
201
202
|
|
202
203
|
|
203
204
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module TkhAuthentication
|
4
|
+
module Generators
|
5
|
+
class UpdateLocalesGenerator < ::Rails::Generators::Base
|
6
|
+
# WARNING - sharing translations and using the ones from the install generator
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def copy_locales
|
10
|
+
puts 'creating locale files'
|
11
|
+
I18n.available_locales.each do |l|
|
12
|
+
copy_file "locales/#{l.to_s}.yml", "config/locales/tkh_authentication.#{l.to_s}.yml"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -13,5 +13,9 @@ module TkhAuthenticationActionControllerExtension
|
|
13
13
|
def authenticate
|
14
14
|
redirect_to login_url, alert: t('authentication.warning.login_needed') if current_user.nil?
|
15
15
|
end
|
16
|
+
|
17
|
+
def authenticate_with_admin
|
18
|
+
redirect_to root_url, alert: t('authentication.warning.restricted_access') unless current_user && current_user.admin?
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tkh_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/generators/tkh_authentication/install/templates/locales/en.yml
|
118
118
|
- lib/generators/tkh_authentication/install/templates/locales/es.yml
|
119
119
|
- lib/generators/tkh_authentication/install/templates/locales/fr.yml
|
120
|
+
- lib/generators/tkh_authentication/update_locales/update_locales_generator.rb
|
120
121
|
- lib/tasks/tkh_authentication_tasks.rake
|
121
122
|
- lib/tkh_authentication/tkh_authentication_action_controller_extension.rb
|
122
123
|
- lib/tkh_authentication/tkh_authentication_helper.rb
|
@@ -170,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
171
|
version: '0'
|
171
172
|
segments:
|
172
173
|
- 0
|
173
|
-
hash:
|
174
|
+
hash: 1167145318761715890
|
174
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
176
|
none: false
|
176
177
|
requirements:
|
@@ -179,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
180
|
version: '0'
|
180
181
|
segments:
|
181
182
|
- 0
|
182
|
-
hash:
|
183
|
+
hash: 1167145318761715890
|
183
184
|
requirements: []
|
184
185
|
rubyforge_project:
|
185
186
|
rubygems_version: 1.8.23
|