C0 code coverage information
Generated on Sun Jun 11 23:15:16 CEST 2006 with rcov 0.6.0
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 module LoginSystem
2
3 protected
4
5 # overwrite this if you want to restrict access to only a few actions
6 # or if you want to check if the user has the correct rights
7 # example:
8 #
9 # # only allow nonbobs
10 # def authorize?(user)
11 # user.login != "bob"
12 # end
13 def authorize?(user)
Called by
46 lib/login_system.rb:47 in 'LoginSystem#login_required'
14 true
15 end
16
17 # overwrite this method if you only want to protect certain actions of the controller
18 # example:
19 #
20 # # don't protect the login and the about method
21 # def protect?(action)
22 # if ['action', 'about'].include?(action)
23 # return false
24 # else
25 # return true
26 # end
27 # end
28 def protect?(action)
Called by
46 lib/login_system.rb:43 in 'LoginSystem#login_required'
29 true
30 end
31
32 # login_required filter. add
33 #
34 # before_filter :login_required
35 #
36 # if the controller should be under any rights management.
37 # for finer access control you can overwrite
38 #
39 # def authorize?(user)
40 #
41 def login_required
Called by
46 vendor/rails/actionpack/lib/action_controller/filters.rb:354 in 'ActionController::Filters::InstanceMethods#call_filters'
42
43 if not protect?(action_name)
Calls
46 LoginSystem#protect? at lib/login_system.rb:28
44 return true
45 end
46
47 if session[:user] and authorize?(session[:user])
Calls
46 LoginSystem#authorize? at lib/login_system.rb:13
48 return true
49 end
50
51 # store current location so that we can
52 # come back after the user logged in
53 store_location
54
55 # call overwriteable reaction to unauthorized access
56 access_denied
57 return false
58 end
59
60 # overwrite if you want to have special behavior in case the user is not authorized
61 # to access the current operation.
62 # the default action is to redirect to the login screen
63 # example use :
64 # a popup window might just close itself for instance
65 def access_denied
66 redirect_to :controller=>"/accounts", :action =>"login"
67 end
68
69 # store current uri in the session.
70 # we can return to this location by calling return_location
71 def store_location
72 session[:return_to] = request.request_uri
73 end
74
75 # move to the last store_location call or to the passed default one
76 def redirect_back_or_default(default)
Called by
2 app/controllers/accounts_controller.rb:10 in 'AccountsController#login'
77 if session[:return_to].nil?
Calls
2 ActionController::TestSession#[] at vendor/rails/actionpack/lib/action_controller/test_process.rb:258
78 redirect_to default
Calls
1 ActionController::Base#redirect_to at vendor/rails/actionpack/lib/action_controller/base.rb:752
79 else
80 redirect_to_url session[:return_to]
Calls
1 ActionController::TestSession#[] at vendor/rails/actionpack/lib/action_controller/test_process.rb:258
1 ActionController::Base#redirect_to_url at vendor/rails/actionpack/lib/action_controller/deprecated_redirects.rb:12
81 session[:return_to] = nil
Calls
1 ActionController::TestSession#[]= at vendor/rails/actionpack/lib/action_controller/test_process.rb:262
82 end
83 end
84
85 end
Generated using the rcov code coverage analysis tool for Ruby version 0.6.0.