cmpa_auth 1.0.3 → 1.0.4
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.
- data/CHANGELOG.rdoc +7 -1
- data/README.rdoc +4 -4
- data/app/controllers/sessions_controller.rb +1 -1
- data/lib/cmpa_auth/rails_helpers.rb +2 -36
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
== 1.0.
|
1
|
+
== 1.0.4 released 2009-12-16
|
2
|
+
|
3
|
+
* Renomeado o before_filter de autentica��o <tt>check_authentication</tt> para <tt>cmpa_authenticate</tt>.
|
4
|
+
* Removido o m�todo helper <tt>cmpa_authenticate</tt> em favor do pr�prio before_filter do Rails.
|
5
|
+
* Adicionada se��o no README explicando como restringir a autentica��o somente para algumas actions.
|
6
|
+
|
7
|
+
== 1.0.3 released 2009-12-10
|
2
8
|
|
3
9
|
* Adicionado suporte a customiza��o do filtro de autentica��o com o m�todo <tt>cmpa_authenticate</tt>.
|
4
10
|
* Adicionada a pasta <tt>app/views/application</tt> com os arquivos de cabe�alho e login para serem utilizados em no layout padr�o.
|
data/README.rdoc
CHANGED
@@ -121,15 +121,15 @@ oferecer o seguinte link na view:
|
|
121
121
|
|
122
122
|
A tela de login � exibida automaticamente caso o usu�rio n�o esteja logado, a
|
123
123
|
n�o ser que voc� queira que certas actions de um determinado controller n�o
|
124
|
-
rodem o <tt>before_filter</tt>. Isso � feito
|
125
|
-
|
124
|
+
rodem o <tt>before_filter</tt>. Isso � feito sobrescrevendo o pr�prio filtro
|
125
|
+
(cmpa_authenticate) no controller. Por exemplo:
|
126
126
|
|
127
127
|
class PostController < ApplicationController
|
128
|
-
|
128
|
+
before_filter :cmpa_authenticate, :except => :index
|
129
129
|
end
|
130
130
|
|
131
131
|
class NewsController < ApplicationController
|
132
|
-
|
132
|
+
before_filter :cmpa_authenticate, :only => [:new, :create, :edit, :update]
|
133
133
|
end
|
134
134
|
|
135
135
|
Copyright (c) 2009 CMPA - Assessoria de Inform�tica
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class SessionsController < ApplicationController
|
2
2
|
|
3
|
-
before_filter :
|
3
|
+
before_filter :cmpa_authenticate, :only => :index
|
4
4
|
|
5
5
|
def index
|
6
6
|
@sistemas = CmpaAuth::Authentication.allowed_systems(session[:lotacao_temporaria_id]).sort_by(&:nome)
|
@@ -12,7 +12,7 @@ module CmpaAuth
|
|
12
12
|
def self.included(receiver) #:nodoc:
|
13
13
|
receiver.class_eval do
|
14
14
|
|
15
|
-
before_filter :
|
15
|
+
before_filter :cmpa_authenticate
|
16
16
|
helper_method :current_user, :current_lotacao, :logged_in?
|
17
17
|
|
18
18
|
rescue_from CmpaAuth::AccessDenied, :with => lambda { render_403 }
|
@@ -25,43 +25,9 @@ module CmpaAuth
|
|
25
25
|
render :template => "rescues/403", :status => 403, :layout => false
|
26
26
|
end
|
27
27
|
|
28
|
-
#
|
29
|
-
# Permite sobrescrever o comportamento do filtro de autenticação padrão.
|
30
|
-
#
|
31
|
-
# === Exemplos
|
32
|
-
#
|
33
|
-
# class PostController < ApplicationController
|
34
|
-
# check_authentication :except => :index
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# class NewsController < ApplicationController
|
38
|
-
# check_authentication :only => [:new, :create, :edit, :update]
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
def self.cmpa_authenticate(options = {})
|
42
|
-
options.to_options!
|
43
|
-
this_controller_name = controller_name
|
44
|
-
actions = Array(options[:only] || options[:except]).map(&:to_s)
|
45
|
-
|
46
|
-
self.class_eval do
|
47
|
-
if options[:only]
|
48
|
-
define_method :check_authentication do
|
49
|
-
redirect_to new_session_url if !logged_in? && controller_name == this_controller_name && actions.include?(action_name)
|
50
|
-
end
|
51
|
-
elsif options[:except]
|
52
|
-
define_method :check_authentication do
|
53
|
-
redirect_to new_session_url if !logged_in? && controller_name == this_controller_name && !actions.include?(action_name)
|
54
|
-
end
|
55
|
-
else
|
56
|
-
# Como o método check_authentication não foi sobrescrito a sua
|
57
|
-
# implementação padrão será chamada.
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
28
|
private
|
63
29
|
|
64
|
-
def
|
30
|
+
def cmpa_authenticate
|
65
31
|
redirect_to new_session_url unless logged_in?
|
66
32
|
end
|
67
33
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmpa_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "CMPA Assessoria de Inform\xC3\xA1tica"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-16 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|