From 53357bf4998aa6087ca3d4f144de83701022a2a1 Mon Sep 17 00:00:00 2001 From: David Cabo Date: Tue, 2 Aug 2011 14:50:57 +0200 Subject: New Request wireframe: implemente modal sign-in process --- app/controllers/user_controller.rb | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'app/controllers/user_controller.rb') diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index d3c42c7f1..7b99be393 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -72,6 +72,10 @@ 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) @@ -80,7 +84,7 @@ class UserController < ApplicationController redirect_to signin_url(:r => params[:r], :again => 1) return end - render :action => 'no_cookies' + render :action => 'no_cookies', :layout => layout return end end @@ -92,13 +96,13 @@ class UserController < ApplicationController if not params[:user_signin] # First time page is shown - render :action => 'sign' + render :action => 'sign', :layout => layout 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' + render :action => 'sign', :layout => layout return else # Successful login @@ -106,7 +110,12 @@ class UserController < ApplicationController session[:user_id] = @user_signin.id session[:user_circumstance] = nil session[:remember_me] = params[:remember_me] ? true : false - do_post_redirect @post_redirect + + if @is_modal_dialog + render :action => 'signin_successful', :layout => layout + else + do_post_redirect @post_redirect + end else send_confirmation_mail @user_signin end @@ -119,11 +128,15 @@ 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' + render :action => 'sign', :layout => layout else user_alreadyexists = User.find_user_by_email(params[:user_signup][:email]) if user_alreadyexists -- cgit v1.2.3 From 07933c860cea05df05acde5b5e321e2d78911f60 Mon Sep 17 00:00:00 2001 From: David Cabo Date: Wed, 10 Aug 2011 01:14:51 +0200 Subject: Select layout for User controller (modal/non-modal) using Rails baked-in mechanism, much cleaner and robust --- app/controllers/user_controller.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'app/controllers/user_controller.rb') 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 -- cgit v1.2.3 From a63e598b9e0ddfa7ac695b1be41aaace6c0eb628 Mon Sep 17 00:00:00 2001 From: David Cabo Date: Thu, 11 Aug 2011 03:50:10 +0200 Subject: Move log-in point to before Preview and fix modal sign-in and sign-up redirects --- app/controllers/user_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/controllers/user_controller.rb') diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 3dcdf973b..3e3913fae 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -109,7 +109,7 @@ class UserController < ApplicationController session[:user_circumstance] = nil session[:remember_me] = params[:remember_me] ? true : false - if @is_modal_dialog + if is_modal_dialog render :action => 'signin_successful' else do_post_redirect @post_redirect @@ -507,10 +507,13 @@ class UserController < ApplicationController private + def is_modal_dialog + (params[:modal].to_i != 0) + end + # 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' + is_modal_dialog ? 'no_chrome' : 'default' end # Decide where we are going to redirect back to after signin/signup, and record that -- cgit v1.2.3