projects
/
depot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Finished Chapter 12
[depot.git]
/
app
/
controllers
/
application.rb
diff --git
a/app/controllers/application.rb
b/app/controllers/application.rb
index fea87e2d210d5e5dfe122bfcc526fb008889ab8c..fe5e10108c6b113c81ebd84c398559c229a91534 100644
(file)
--- a/
app/controllers/application.rb
+++ b/
app/controllers/application.rb
@@
-2,6
+2,8
@@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
+ layout "store"
+ before_filter :authorize, :except => :login
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details
@@
-12,4
+14,13
@@
class ApplicationController < ActionController::Base
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
# filter_parameter_logging :password
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
# filter_parameter_logging :password
+
+ protected
+ def authorize
+ unless User.find_by_id(session[:user_id])
+ session[:original_uri] = request.request_uri
+ flash[:notice] = "Please log in"
+ redirect_to :controller => 'admin', 'action' => 'login'
+ end
+ end
end
end