tkh_authentication 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.0.9
6
+
7
+ * Administrator can enable other users do become admins or remove their privileges
8
+ * localized a few users index view strings
9
+ * Refactored migrations generator
10
+ * Added an update rake task
11
+
12
+
5
13
  ## 0.0.8
6
14
 
7
15
  * User has_many pages
@@ -1,7 +1,7 @@
1
1
  class UsersController < ApplicationController
2
2
 
3
3
  before_filter :authenticate, only: 'index'
4
- before_filter :authenticate_with_admin, only: 'index'
4
+ before_filter :authenticate_with_admin, except: ['new', 'create']
5
5
 
6
6
  def index
7
7
  @users = User.by_recent
@@ -23,4 +23,18 @@ class UsersController < ApplicationController
23
23
  end
24
24
  end
25
25
 
26
+ def make_admin
27
+ user = User.find(params[:id])
28
+ user.admin = true
29
+ user.save
30
+ redirect_to users_path, notice: t('authentication.admin_enabled_confirmation')
31
+ end
32
+
33
+ def remove_admin
34
+ user = User.find(params[:id])
35
+ user.admin = false
36
+ user.save
37
+ redirect_to users_path, notice: t('authentication.admin_disabled_confirmation')
38
+ end
39
+
26
40
  end
@@ -3,8 +3,8 @@
3
3
  <table class='table table-striped'>
4
4
  <thead>
5
5
  <tr>
6
- <th>Name</th>
7
- <th>Email</th>
6
+ <th><%= t 'authentication.name' %></th>
7
+ <th><%= t 'activerecord.attributes.user.email' %></th>
8
8
  <th>Admin?</th>
9
9
  </tr>
10
10
  </thead>
@@ -14,7 +14,13 @@
14
14
  <tr>
15
15
  <td><%= user.name %></td>
16
16
  <td><%= user.email %></td>
17
- <td><%= user.admin? ? '✓' : 'X' %></td>
17
+ <td>
18
+ <% unless user.admin? %>
19
+ <span class="label label-important">X</span> <%= link_to t('authentication.enable_admin'), make_admin_user_path(user), class: 'btn btn-mini', method: :post %>
20
+ <% else %>
21
+ <span class="label label-success">✓</span> <%= link_to t('authentication.disable_admin'), remove_admin_user_path(user), class: 'btn btn-mini', method: :post %>
22
+ <% end -%>
23
+ </td>
18
24
  </tr>
19
25
  <% end %>
20
26
  </tbody>
data/config/routes.rb CHANGED
@@ -4,7 +4,12 @@ Rails.application.routes.draw do
4
4
  get 'login', to: 'sessions#new', as: 'login'
5
5
  get 'logout', to: 'sessions#destroy', as: 'logout'
6
6
 
7
- resources :users
7
+ resources :users do
8
+ member do
9
+ post :make_admin
10
+ post :remove_admin
11
+ end
12
+ end
8
13
  resources :sessions
9
14
  resources :password_resets
10
15
  end
@@ -3,19 +3,24 @@ de:
3
3
  activerecord:
4
4
  attributes:
5
5
  user:
6
- first_name: "prénom"
7
- last_name: "nom de famille"
8
- email: "courriel"
9
- password: 'mot de passe'
10
- password_confirmation: 'confirmation de mot de passe'
6
+ first_name: "first name"
7
+ last_name: "last name"
8
+ email: "email"
9
+ password: 'password'
10
+ password_confirmation: 'password confirmation'
11
11
 
12
12
  authentication:
13
+ admin_disabled_confirmation: 'you have stripped this user of the administrator privileges'
14
+ admin_enabled_confirmation: 'you have empowered this user to be an administrator'
13
15
  create_account: 'create your account'
16
+ disable_admin: 'disable'
17
+ enable_admin: 'enable'
14
18
  forgot_password: "forgot your password?"
15
19
  login_confirmation: "You have been logged in!"
16
20
  login_now: "log in"
17
21
  logout: "log out"
18
22
  logout_confirmation: "You have been logged out!"
23
+ name: 'name'
19
24
  not_registered: "you don't have an account yet?"
20
25
  password_reset_confirmation: "Your password has been successfully reset!"
21
26
  password_reset_email_subject: "Password reset"
@@ -1,12 +1,26 @@
1
1
  en:
2
+
3
+ activerecord:
4
+ attributes:
5
+ user:
6
+ first_name: "first name"
7
+ last_name: "last name"
8
+ email: "email"
9
+ password: 'password'
10
+ password_confirmation: 'password confirmation'
2
11
 
3
12
  authentication:
13
+ admin_disabled_confirmation: 'you have stripped this user of the administrator privileges'
14
+ admin_enabled_confirmation: 'you have empowered this user to be an administrator'
4
15
  create_account: 'create your account'
16
+ disable_admin: 'disable'
17
+ enable_admin: 'enable'
5
18
  forgot_password: "forgot your password?"
6
19
  login_confirmation: "You have been logged in!"
7
20
  login_now: "log in"
8
21
  logout: "log out"
9
22
  logout_confirmation: "You have been logged out!"
23
+ name: 'name'
10
24
  not_registered: "you don't have an account yet?"
11
25
  password_reset_confirmation: "Your password has been successfully reset!"
12
26
  password_reset_email_subject: "Password reset"
@@ -10,12 +10,17 @@ es:
10
10
  password_confirmation: 'confirmar contraseña'
11
11
 
12
12
  authentication:
13
+ admin_disabled_confirmation: "Este usuario no es un administrador"
14
+ admin_enabled_confirmation: 'Este usuario es ahora un administrador'
13
15
  create_account: 'crea tu cuenta'
16
+ disable_admin: 'eliminar el poder'
17
+ enable_admin: 'autorizar'
14
18
  forgot_password: '¿olvidaste tu contraseña?'
15
19
  login_confirmation: 'Conectado con éxito'
16
20
  login_now: "conectar"
17
21
  logout: "salir"
18
22
  logout_confirmation: 'Se ha cerrado la sesión'
23
+ name: 'nombre'
19
24
  not_registered: 'no tienes una cuenta todavía'
20
25
  password_reset_confirmation: 'Tu contraseña se ha restablecido correctamente.'
21
26
  password_reset_email_subject: 'Restablecimiento de contraseña.'
@@ -10,12 +10,17 @@ fr:
10
10
  password_confirmation: 'confirmation de mot de passe'
11
11
 
12
12
  authentication:
13
+ admin_disabled_confirmation: "cet utilisateur n'est plus un administrateur"
14
+ admin_enabled_confirmation: 'cet utilisateur est maintenant un administrateur'
13
15
  create_your_account: 'créez votre compte'
16
+ disable_admin: 'enlever le pouvoir'
17
+ enable_admin: 'donner le pouvoir'
14
18
  forgot_password: "avez vous oublié votre mot de passe ?"
15
19
  login_confirmation: "Merci de vous être identifié !"
16
20
  login_now: "Identifiez-vous"
17
21
  logout: "déconnexion"
18
22
  logout_confirmation: "Merci pour votre visite."
23
+ name: 'nom'
19
24
  not_registered: "vous n'avez pas encore de compte ?"
20
25
  password_reset_confirmation: "Votre mot de passe a été réinitialisé avec succès !"
21
26
  password_reset_email_subject: "Réinitialisation du mot de passe"
@@ -2,7 +2,7 @@ require 'rails/generators/migration'
2
2
 
3
3
  module TkhAuthentication
4
4
  module Generators
5
- class CreateMigrationGenerator < ::Rails::Generators::Base
5
+ class CreateOrUpdateMigrationsGenerator < ::Rails::Generators::Base
6
6
  include Rails::Generators::Migration
7
7
  source_root File.expand_path('../templates', __FILE__)
8
8
  desc "add the migrations and locale files"
@@ -1,7 +1,13 @@
1
1
  namespace :tkh_authentication do
2
2
  desc "Create migrations and locale files"
3
3
  task :install do
4
- system 'rails g tkh_authentication:create_migration'
5
- system 'rails g tkh_authentication:create_or_update_locales'
4
+ system 'rails g tkh_authentication:create_or_update_migrations'
5
+ system 'rails g tkh_authentication:create_or_update_locales -f'
6
+ end
7
+
8
+ desc "Update files. Skip existing migrations. Force overwrite locales"
9
+ task :update do
10
+ system 'rails g tkh_authentication:create_or_update_migrations -s'
11
+ system 'rails g tkh_authentication:create_or_update_locales -f'
6
12
  end
7
13
  end
@@ -1,3 +1,3 @@
1
1
  module TkhAuthentication
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  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.8
4
+ version: 0.0.9
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-09-04 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -112,13 +112,13 @@ files:
112
112
  - app/views/users/index.html.erb
113
113
  - app/views/users/new.html.erb
114
114
  - config/routes.rb
115
- - lib/generators/tkh_authentication/create_migration/create_migration_generator.rb
116
- - lib/generators/tkh_authentication/create_migration/templates/create_users.rb
117
115
  - lib/generators/tkh_authentication/create_or_update_locales/create_or_update_locales_generator.rb
118
116
  - lib/generators/tkh_authentication/create_or_update_locales/templates/de.yml
119
117
  - lib/generators/tkh_authentication/create_or_update_locales/templates/en.yml
120
118
  - lib/generators/tkh_authentication/create_or_update_locales/templates/es.yml
121
119
  - lib/generators/tkh_authentication/create_or_update_locales/templates/fr.yml
120
+ - lib/generators/tkh_authentication/create_or_update_migrations/create_or_update_migrations_generator.rb
121
+ - lib/generators/tkh_authentication/create_or_update_migrations/templates/create_users.rb
122
122
  - lib/tasks/tkh_authentication_tasks.rake
123
123
  - lib/tkh_authentication/tkh_authentication_action_controller_extension.rb
124
124
  - lib/tkh_authentication/tkh_authentication_helper.rb
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: -2564773836693246689
175
+ hash: -3817198509977056142
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: -2564773836693246689
184
+ hash: -3817198509977056142
185
185
  requirements: []
186
186
  rubyforge_project:
187
187
  rubygems_version: 1.8.23