<commit_before>class UserController < ApplicationController

  skip_before_action :login_required, :only => [:new, :create, :join]
  skip_before_action :verified_email_required, :only => [:edit, :update, :verify]

  def new
    @user_invite = UserInvite.active.find_by!(:uuid => params[:invite_token])
    @user = User.new
    @user.email_address = @user_invite.email_address
    render :layout => 'sub'
  end

  def create
    @user_invite = UserInvite.active.find_by!(:uuid => params[:invite_token])
    @user = User.new(params.require(:user).permit(:first_name, :last_name, :email_address, :password, :password_confirmation))
    if @user.save
      @user_invite.accept(@user)
      AppMailer.new_user(@user).deliver
      self.current_user = @user
      redirect_to verify_path(:return_to => params[:return_to])
    else
      render 'new', :layout => 'sub'
    end
  end

  def join
    if @invite = UserInvite.where(:uuid => params[:token]).where("expires_at > ?", Time.now).first
      if logged_in?
        if request.post?
          @invite.accept(current_user)
          redirect_to_with_json root_path(:nrd => 1), :notice => "Invitation has been accepted successfully. You now have access to this organization."
        elsif request.delete?
          @invite.reject
          redirect_to_with_json root_path(:nrd => 1), :notice => "Invitation has been rejected successfully."
        else
          @organizations = @invite.organizations.order(:name).to_a
        end
      else
        redirect_to new_signup_path(params[:token])
      end
    else
      redirect_to_with_json root_path(:nrd => 1), :alert => "The invite URL you have has expired. Please ask the person who invited you to re-send your invitation."<commit_msg>verify new users straight away<commit_after>class UserController < ApplicationController

  skip_before_action :login_required, :only => [:new, :create, :join]
  skip_before_action :verified_email_required, :only => [:edit, :update, :verify]

  def new
    @user_invite = UserInvite.active.find_by!(:uuid => params[:invite_token])
    @user = User.new
    @user.email_address = @user_invite.email_address
    render :layout => 'sub'
  end

  def create
    @user_invite = UserInvite.active.find_by!(:uuid => params[:invite_token])
    @user = User.new(params.require(:user).permit(:first_name, :last_name, :email_address, :password, :password_confirmation))
    @user.email_verified_at = Time.now
    if @user.save
      @user_invite.accept(@user)
      self.current_user = @user
      redirect_to root_path
    else
      render 'new', :layout => 'sub'
    end
  end

  def join
    if @invite = UserInvite.where(:uuid => params[:token]).where("expires_at > ?", Time.now).first
      if logged_in?
        if request.post?
          @invite.accept(current_user)
          redirect_to_with_json root_path(:nrd => 1), :notice => "Invitation has been accepted successfully. You now have access to this organization."
        elsif request.delete?
          @invite.reject
          redirect_to_with_json root_path(:nrd => 1), :notice => "Invitation has been rejected successfully."
        else
          @organizations = @invite.organizations.order(:name).to_a
        end
      else
        redirect_to new_signup_path(params[:token])
      end
    else
      redirect_to_with_json root_path(:nrd => 1), :alert => "The invite URL you have has expired. Please ask the person who invited you to re-send your invitation."
{'fraction_non_alphanumeric': 0.1154513888888889, 'fraction_numerical': 0.001736111111111111, 'mean_word_length': 3.437740693196406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4872105', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1058, 'n_words': 255}