aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/user_controller.rb
diff options
context:
space:
mode:
authorDavid Cabo <david@calibea.com>2011-08-10 01:14:51 +0200
committerDavid Cabo <david@calibea.com>2011-08-10 01:14:51 +0200
commit07933c860cea05df05acde5b5e321e2d78911f60 (patch)
treea79145929c16c5eba64c66b65d28aba9ea947b1d /app/controllers/user_controller.rb
parent1cd04d3604e16851c711c2423b46dfab18d652d8 (diff)
Select layout for User controller (modal/non-modal) using Rails baked-in mechanism, much cleaner and robust
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r--app/controllers/user_controller.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 7b99be393..3dcdf973b 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -8,6 +8,8 @@
class UserController < ApplicationController
+ layout :select_layout
+
protect_from_forgery :only => [ :contact,
:set_profile_photo,
:signchangeemail,
@@ -72,10 +74,6 @@ class UserController < ApplicationController
def signin
work_out_post_redirect
- # when logging in through a modal iframe, don't display chrome around the content
- @is_modal_dialog = (params[:modal].to_i != 0)
- layout = @is_modal_dialog ? 'no_chrome' : 'default'
-
# make sure we have cookies
if session.instance_variable_get(:@dbman)
if not session.instance_variable_get(:@dbman).instance_variable_get(:@original)
@@ -84,7 +82,7 @@ class UserController < ApplicationController
redirect_to signin_url(:r => params[:r], :again => 1)
return
end
- render :action => 'no_cookies', :layout => layout
+ render :action => 'no_cookies'
return
end
end
@@ -96,13 +94,13 @@ class UserController < ApplicationController
if not params[:user_signin]
# First time page is shown
- render :action => 'sign', :layout => layout
+ render :action => 'sign'
return
else
@user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false)
if @user_signin.errors.size > 0
# Failed to authenticate
- render :action => 'sign', :layout => layout
+ render :action => 'sign'
return
else
# Successful login
@@ -112,7 +110,7 @@ class UserController < ApplicationController
session[:remember_me] = params[:remember_me] ? true : false
if @is_modal_dialog
- render :action => 'signin_successful', :layout => layout
+ render :action => 'signin_successful'
else
do_post_redirect @post_redirect
end
@@ -128,15 +126,11 @@ class UserController < ApplicationController
def signup
work_out_post_redirect
- # when logging in through a modal iframe, don't display chrome around the content
- @is_modal_dialog = (params[:modal].to_i != 0)
- layout = @is_modal_dialog ? 'no_chrome' : 'default'
-
# Make the user and try to save it
@user_signup = User.new(params[:user_signup])
if !@user_signup.valid?
# Show the form
- render :action => 'sign', :layout => layout
+ render :action => 'sign'
else
user_alreadyexists = User.find_user_by_email(params[:user_signup][:email])
if user_alreadyexists
@@ -513,6 +507,12 @@ class UserController < ApplicationController
private
+ # when logging in through a modal iframe, don't display chrome around the content
+ def select_layout
+ @is_modal_dialog = (params[:modal].to_i != 0)
+ @is_modal_dialog ? 'no_chrome' : 'default'
+ end
+
# Decide where we are going to redirect back to after signin/signup, and record that
def work_out_post_redirect
# Redirect to front page later if nothing else specified