X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/07b834785f709628baaf3678cd8d81cf72a6ef60..5275794aec3e4d06292db57afe6ee2e742be7b0b:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 92a602ff1..de07e4b53 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -253,16 +253,21 @@ class UserController < ApplicationController def new @title = t 'user.new.title' @referer = params[:referer] || session[:referer] - @user = User.new(:email => params[:email], - :email_confirmation => params[:email], - :display_name => params[:nickname], - :openid_url => params[:openid]) - if session[:user] + if @user # The user is logged in already, so don't show them the signup # page, instead send them to the home page - redirect_to :controller => 'site', :action => 'index' - elsif not params['openid'].nil? + if @referer + redirect_to @referer + else + redirect_to :controller => 'site', :action => 'index' + end + elsif params.key?(:openid) + @user = User.new(:email => params[:email], + :email_confirmation => params[:email], + :display_name => params[:nickname], + :openid_url => params[:openid]) + flash.now[:notice] = t 'user.new.openid association' end end @@ -331,6 +336,7 @@ class UserController < ApplicationController token.destroy session[:user] = user.id + cookies.permanent["_osm_username"] = user.display_name if referer.nil? flash[:notice] = t('user.confirm.success') + "

" + t('user.confirm.before you start') @@ -383,6 +389,7 @@ class UserController < ApplicationController end token.destroy session[:user] = @user.id + cookies.permanent["_osm_username"] = @user.display_name redirect_to :action => 'account', :display_name => @user.display_name else flash[:error] = t 'user.confirm_email.failure' @@ -610,6 +617,8 @@ private ## # process a successful login def successful_login(user) + cookies.permanent["_osm_username"] = user.display_name + session[:user] = user.id session_expires_after 1.month if session[:remember_me]