X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/3227f401935e809edc91d360339220a89567db7a..88bf67b0923b1376ae6320597c70ce65e5fb1073:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 9ef1ab409..3622b037d 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,6 +1,7 @@ class UserController < ApplicationController layout :choose_layout + skip_before_filter :verify_authenticity_token, :only => [:api_details, :api_gpx_files] before_filter :disable_terms_redirect, :only => [:terms, :save, :logout, :api_details] before_filter :authorize, :only => [:api_details, :api_gpx_files] before_filter :authorize_web, :except => [:api_details, :api_gpx_files] @@ -48,7 +49,7 @@ class UserController < ApplicationController if params[:user] and params[:user][:openid_url] and @user.pass_crypt.empty? # We are creating an account with OpenID and no password # was specified so create a random one - @user.pass_crypt = ActiveSupport::SecureRandom.base64(16) + @user.pass_crypt = SecureRandom.base64(16) @user.pass_crypt_confirmation = @user.pass_crypt end @@ -253,11 +254,20 @@ class UserController < ApplicationController @title = t 'user.new.title' @referer = params[:referer] || session[:referer] - 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 @@ -517,7 +527,7 @@ private end # Start the authentication - authenticate_with_open_id(openid_expand_url(openid_url), :required => required) do |result, identity_url, sreg, ax| + authenticate_with_open_id(openid_expand_url(openid_url), :method => :get, :required => required) do |result, identity_url, sreg, ax| if result.successful? # We need to use the openid url passed back from the OpenID provider # rather than the one supplied by the user, as these can be different. @@ -565,7 +575,7 @@ private def openid_verify(openid_url, user) user.openid_url = openid_url - authenticate_with_open_id(openid_expand_url(openid_url)) do |result, identity_url| + authenticate_with_open_id(openid_expand_url(openid_url), :method => :get) do |result, identity_url| if result.successful? # We need to use the openid url passed back from the OpenID provider # rather than the one supplied by the user, as these can be different.