Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 24
- Log:
Initial import of Collaboa 0.5.6 from downloaded Tarball. Collaboa is
a Ruby On Rails based bug tracker and SVN repository browsing tool.
- Author:
- adh
- Date:
- Mon Jul 24 21:54:39 +0100 2006
- Size:
- 2062 Bytes
1 | require_dependency "user" |
2 | |
3 | module LoginSystem |
4 | |
5 | protected |
6 | |
7 | # overwrite this if you want to restrict access to only a few actions |
8 | # or if you want to check if the user has the correct rights |
9 | # example: |
10 | # |
11 | # # only allow nonbobs |
12 | # def authorize?(user) |
13 | # user.login != "bob" |
14 | # end |
15 | def authorize?(user) |
16 | true |
17 | end |
18 | |
19 | # overwrite this method if you only want to protect certain actions of the controller |
20 | # example: |
21 | # |
22 | # # don't protect the login and the about method |
23 | # def protect?(action) |
24 | # if ['action', 'about'].include?(action) |
25 | # return false |
26 | # else |
27 | # return true |
28 | # end |
29 | # end |
30 | def protect?(action) |
31 | true |
32 | end |
33 | |
34 | # login_required filter. add |
35 | # |
36 | # before_filter :login_required |
37 | # |
38 | # if the controller should be under any rights management. |
39 | # for finer access control you can overwrite |
40 | # |
41 | # def authorize?(user) |
42 | # |
43 | def login_required |
44 | |
45 | if not protect?(action_name) |
46 | return true |
47 | end |
48 | |
49 | if authorize?(current_user) |
50 | return true |
51 | end |
52 | |
53 | # store current location so that we can |
54 | # come back after the user logged in |
55 | store_location |
56 | |
57 | # call overwriteable reaction to unauthorized access |
58 | access_denied |
59 | return false |
60 | end |
61 | |
62 | # overwrite if you want to have special behavior in case the user is not authorized |
63 | # to access the current operation. |
64 | # the default action is to redirect to the login screen |
65 | # example use : |
66 | # a popup window might just close itself for instance |
67 | def access_denied |
68 | redirect_to :controller=>"/login", :action =>"login" |
69 | end |
70 | |
71 | # store current uri in the session. |
72 | # we can return to this location by calling return_location |
73 | def store_location |
74 | session[:return_to] = request.request_uri |
75 | end |
76 | |
77 | # move to the last store_location call or to the passed default one |
78 | def redirect_back_or_default(default) |
79 | if session[:return_to].nil? |
80 | redirect_to default |
81 | else |
82 | redirect_to session[:return_to] |
83 | session[:return_to] = nil |
84 | end |
85 | end |
86 | |
87 | end |