Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Side by Side Diff: app/controllers/account_controller.rb

Issue 2323: Upgrade to Rails 2 SVN Base: http://familyconnect.rubyforge.org/svn/trunk/
Patch Set: Created 6 months, 3 weeks ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 require 'ostruct' 1 require 'ostruct'
2 2
3 class AccountController < ApplicationController 3 class AccountController < ApplicationController
4 before_filter :login_required 4 before_filter :login_required
5 @@confirmation = '1bc7ac90bdd8e9f0121dcf99d83528b5' 5 @@confirmation = '1bc7ac90bdd8e9f0121dcf99d83528b5'
6 6
7 def login 7 def login
8 case @request.method 8 case request.method
9 when :post 9 when :post
10 if @session[:user] = User.authenticate(@params[:user_login], @params[:user _password]) 10 logger.warn(" --> 1 session: #{session[:user]}")
11 11 if session[:user] = User.authenticate(params[:user_login], params[:user_pa ssword])
12 logger.warn(" --> 2 session: #{session[:user]}")
12 flash[:notice] = "Sign-in successful" 13 flash[:notice] = "Sign-in successful"
13 redirect_back_or_default :action => "welcome" 14 redirect_back_or_default :action => "welcome"
14 else 15 else
15 flash.now[:error] = "Sign-in unsuccessful" 16 flash.now[:error] = "Sign-in unsuccessful"
16 17 @login = params[:user_login]
17 @login = @params[:user_login]
18 end 18 end
19 end 19 end
20 end 20 end
21 21
22 def signup 22 def signup
23 if User.count == 0 23 if User.count == 0
24 @admin_signup = true 24 @admin_signup = true
25 @menu_left = 'menu_left_admin_signup' 25 @menu_left = 'menu_left_admin_signup'
26 end 26 end
27 27
28 @user = User.new(@params[:user]) 28 @user = User.new(params[:user])
29 @security = OpenStruct.new(params[:security]) 29 @security = OpenStruct.new(params[:security])
30 if @request.post? 30 if request.post?
31 if @admin_signup 31 if @admin_signup
32 @user.admin = true 32 @user.admin = true
33 if @user.save 33 if @user.save
34 @session[:user] = User.authenticate(@user.login, @params[:user][:passw ord]) 34 session[:user] = User.authenticate(@user.login, params[:user][:passwor d])
35 redirect_to :controller => 'welcome', :action => 'first_time_done' 35 redirect_to :controller => 'welcome', :action => 'first_time_done'
36 end 36 end
37 elsif params[:security][:password] == Setting[:family_password] 37 elsif params[:security][:password] == Setting[:family_password]
38 if @user.save 38 if @user.save
39 @session[:user] = User.authenticate(@user.login, @params[:user][:passw ord]) 39 session[:user] = User.authenticate(@user.login, params[:user][:passwor d])
40 flash[:notice] = "Signup successful" 40 flash[:notice] = "Signup successful"
41 redirect_back_or_default :action => "welcome" 41 redirect_back_or_default :action => "welcome"
42 end 42 end
43 else 43 else
44 flash.now[:error] = "Family password was incorrect." 44 flash.now[:error] = "Family password was incorrect."
45 end 45 end
46 end 46 end
47 end 47 end
48 48
49 def logout 49 def logout
50 @session[:user] = nil 50 session[:user] = nil
51 end 51 end
52 52
53 def welcome 53 def welcome
54 end 54 end
55 55
56 def edit 56 def edit
57 if params[:id] 57 if params[:id]
58 if current_user.admin? or current_user.id == params[:id].to_i 58 if current_user.admin? or current_user.id == params[:id].to_i
59 @user = User.find(params[:id]) 59 @user = User.find(params[:id])
60 else 60 else
(...skipping 41 matching lines...) Show 10 above Show 10 below
102 end 102 end
103 end 103 end
104 104
105 def show 105 def show
106 @user = User.find(params[:id]) 106 @user = User.find(params[:id])
107 end 107 end
108 108
109 def forgot_password 109 def forgot_password
110 @security = OpenStruct.new(params[:security]) 110 @security = OpenStruct.new(params[:security])
111 if request.post? 111 if request.post?
112 @user = User.find_by_email @security.email 112 @user = User.find_by_email(@security.email)
113 if @user 113 if @user
114 url = url_for({ 114 url = url_for({
115 :controller => 'account', 115 :controller => 'account',
116 :action => 'reset_password', 116 :action => 'reset_password',
117 :id => @user, 117 :id => @user,
118 :confirmation => @@confirmation}, 118 :confirmation => @@confirmation},
119 {:only_path => false}) 119 {:only_path => false})
120 Notifier.deliver_forgot_password(@user, url) 120 Notifier.deliver_forgot_password(@user, url)
121 flash[:notice] = "You have been sent an email containing instructions on how to reset your password." 121 flash[:notice] = "You have been sent an email containing instructions on how to reset your password."
122 redirect_to :action => 'login' 122 redirect_to :action => 'login'
(...skipping 32 matching lines...) Show 10 above Show 10 below
155 end 155 end
156 156
157 def authorize?(user) 157 def authorize?(user)
158 if action_name == 'destroy' 158 if action_name == 'destroy'
159 user.admin? 159 user.admin?
160 else 160 else
161 true 161 true
162 end 162 end
163 end 163 end
164 end 164 end
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r381