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
@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
#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
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'
end
end
end
-
- user
+ return user
end
def go_public
@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
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]