X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/19c5f8aeaab18f314be9bacdc03e83670ca40609..ebcc988376b0dad8a0969803d52b1073420c77b7:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 88ed89b6c..cc12cc9e7 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -36,13 +36,13 @@ class UserController < ApplicationController return end else - @user = User.new(params[:user]) + @user = User.new(params[:user]) - @user.visible = true - @user.data_public = true - @user.description = "" if @user.description.nil? - @user.creation_ip = request.remote_ip - @user.languages = request.user_preferred_languages + @user.visible = true + @user.data_public = true + @user.description = "" if @user.description.nil? + @user.creation_ip = request.remote_ip + @user.languages = request.user_preferred_languages #Set the openid_url to nil as for one it is used #to check if the openid could be validated and secondly #to not get dupplicate conflicts for an empty openid @@ -133,6 +133,8 @@ class UserController < ApplicationController @user.home_lat = params[:user][:home_lat] @user.home_lon = params[:user][:home_lon] + @user.openid_url = nil if (params[:user][:openid_url].length == 0) + if @user.save set_locale @@ -215,6 +217,7 @@ class UserController < ApplicationController #don't want to duplicate the do block #On the other hand it also doesn't matter too much if we ask every time, as the OpenID provider should #remember these results, and shouldn't repromt the user for these data each time. + user = nil authenticate_with_open_id(openid_url, :return_to => request.protocol + request.host_with_port + '/login?referer=' + params[:referer], :optional => [:nickname, :email]) do |result, identity_url, registration| if result.successful? #We need to use the openid url passed back from the OpenID provider @@ -227,6 +230,7 @@ class UserController < ApplicationController if user.visible? and user.active? session[:user] = user.id session_expires_after 1.month if session[:remember] + return user else user = nil flash.now[:error] = t 'user.login.account not active' @@ -253,8 +257,7 @@ class UserController < ApplicationController end end end - - user + return user end def go_public @@ -319,6 +322,10 @@ class UserController < ApplicationController @nickname = params['nickname'] @email = params['email'] @openID = params['openid'] + + if !params['openid'].nil? + flash.now[:notice] = t 'user.new.openID association' + end end def login @@ -332,7 +339,10 @@ class UserController < ApplicationController elsif params[:user] if !params[:user][:openid_url].nil? and !params[:user][:openid_url].empty? session[:remember] = params[:remember_me] - user = open_id_authentication(params[:user][:openid_url]) + #construct the openid request. This will redirect to the OpenID server to ask for validation + #The external OpenID server will then redirect back to the login method and reenters at the top + open_id_authentication(params[:user][:openid_url]) + return else email_or_display_name = params[:user][:email] pass = params[:user][:password]