+
+ allow_thirdparty_images :only => :show
+ allow_social_login :only => :new
+
+ def show
+ @user = User.find_by(:display_name => params[:display_name])
+
+ if @user &&
+ (@user.visible? || current_user&.administrator?)
+ @title = @user.display_name
+ else
+ render_unknown_user params[:display_name]
+ end
+ end
+
+ def new
+ @title = t ".title"
+ @referer = safe_referer(params[:referer])
+
+ parse_oauth_referer @referer
+
+ if current_user
+ # The user is logged in already, so don't show them the signup
+ # page, instead send them to the home page
+ redirect_to @referer || { :controller => "site", :action => "index" }
+ elsif params.key?(:auth_provider) && params.key?(:auth_uid)
+ @email_hmac = params[:email_hmac]
+
+ self.current_user = User.new(:email => params[:email],
+ :display_name => params[:nickname],
+ :auth_provider => params[:auth_provider],
+ :auth_uid => params[:auth_uid])
+
+ if current_user.valid? || current_user.errors[:email].empty?
+ flash.now[:notice] = render_to_string :partial => "auth_association"
+ else
+ flash.now[:warning] = t ".duplicate_social_email"
+ end
+ else
+ check_signup_allowed
+
+ self.current_user = User.new
+ end
+ end
+
+ def create
+ self.current_user = User.new(user_params)
+
+ if check_signup_allowed(current_user.email)
+ if current_user.auth_uid.present?
+ # We are creating an account with external authentication and
+ # no password was specified so create a random one
+ current_user.pass_crypt = SecureRandom.base64(16)
+ current_user.pass_crypt_confirmation = current_user.pass_crypt
+ end
+
+ if current_user.invalid?
+ # Something is wrong with a new user, so rerender the form
+ render :action => "new"
+ else
+ # Save the user record
+ if save_new_user params[:email_hmac]
+ SIGNUP_IP_LIMITER&.update(request.remote_ip)
+ SIGNUP_EMAIL_LIMITER&.update(canonical_email(current_user.email))
+
+ flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo)
+
+ referer = welcome_path(welcome_options(params[:referer]))
+
+ if current_user.status == "active"
+ successful_login(current_user, referer)
+ else
+ session[:pending_user] = current_user.id
+ UserMailer.signup_confirm(current_user, current_user.generate_token_for(:new_user), referer).deliver_later
+ redirect_to :controller => :confirmations, :action => :confirm, :display_name => current_user.display_name
+ end
+ else
+ render :action => "new", :referer => params[:referer]
+ end
+ end
+ end
+ end
+
+ ##
+ # destroy a user, marking them as deleted and removing personal data
+ def destroy
+ @user.soft_destroy!
+ redirect_to user_path(:display_name => params[:display_name])
+ end