Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 206
- Log:
Initial import of Gullery, an open source photo gallery:
http://nubyonrails.com/pages/gullery
- Author:
- rool
- Date:
- Sun May 20 19:05:59 +0100 2007
- Size:
- 2522 Bytes
1 | class AccountController < ApplicationController |
2 | include AuthenticatedSystem |
3 | |
4 | observer :user_observer |
5 | |
6 | before_filter :login_required, :only => [:update_description] |
7 | |
8 | def update_description |
9 | current_user.description = @params[:value] |
10 | if current_user.save |
11 | render :text => textilize(current_user.description) |
12 | end |
13 | end |
14 | |
15 | # Be sure to include AuthenticationSystem in Application Controller instead |
16 | # To require logins, use: |
17 | # |
18 | # before_filter :login_required # restrict all actions |
19 | # before_filter :login_required, :only => [:edit, :update] # only restrict these actions |
20 | # |
21 | # To skip this in a subclassed controller: |
22 | # |
23 | # skip_before_filter :login_required |
24 | |
25 | def index |
26 | redirect_to(:action => 'signup') unless logged_in? or User.count > 0 |
27 | end |
28 | |
29 | # If you want persistent logins, uncomment the second line of #login and add this to your login.rhtml view: |
30 | # |
31 | # |
32 | # Keep in mind that this will cause your session to stick around for 4 weeks. If this is undesirable, use a plain old cookie. |
33 | def login |
34 | return unless request.post? |
35 | ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 4.weeks.from_now) if params[:remember_me] |
36 | self.current_user = User.authenticate(params[:login], params[:password]) |
37 | if current_user |
38 | redirect_back_or_default(:controller => '/') |
39 | flash[:notice] = "Logged in successfully" |
40 | else |
41 | flash[:notice] = "Please try again" |
42 | end |
43 | end |
44 | |
45 | def signup |
46 | if User.count > 0 |
47 | flash[:notice] = 'Someone has already signed up for this installation!' |
48 | redirect_to(:controller => '/') |
49 | return |
50 | end |
51 | @user = User.new(params[:user]) |
52 | return unless request.post? |
53 | @user.website = "http://#{@params[:user][:website]}" |
54 | if @user.save |
55 | self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) |
56 | redirect_back_or_default(:controller => '/') |
57 | flash[:notice] = "Thanks for signing up!" |
58 | end |
59 | end |
60 | |
61 | # Sample method for activating the current user |
62 | #def activate |
63 | # @user = User.find_by_activation_code(params[:id]) |
64 | # if @user and @user.activate |
65 | # self.current_user = @user |
66 | # redirect_back_or_default(:controller => '/account', :action => 'index') |
67 | # flash[:notice] = "Your account has been activated." |
68 | # end |
69 | #end |
70 | |
71 | def logout |
72 | self.current_user = nil |
73 | flash[:notice] = "You have been logged out." |
74 | redirect_back_or_default(:controller => '/') |
75 | end |
76 | |
77 | end |