+ 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"
+ else
+ check_signup_allowed
+ end
+ end
+
+ def create
+ @user = User.new(user_params)
+
+ if check_signup_allowed(@user.email)
+ session[:referer] = params[:referer]
+
+ @user.status = "pending"
+
+ if @user.openid_url.present? && @user.pass_crypt.empty?
+ # We are creating an account with OpenID and no password
+ # was specified so create a random one
+ @user.pass_crypt = SecureRandom.base64(16)
+ @user.pass_crypt_confirmation = @user.pass_crypt
+ end
+
+ if @user.invalid?
+ # Something is wrong with a new user, so rerender the form
+ render :action => "new"
+ elsif @user.openid_url.present?
+ # Verify OpenID before moving on
+ session[:new_user] = @user
+ openid_verify(@user.openid_url, @user)
+ else
+ # Save the user record
+ session[:new_user] = @user
+ redirect_to :action => :terms
+ end