<commit_before>class UsersController < ApplicationController
  load_resource :find_by => :permalink
  authorize_resource
  respond_to :html, :json
 
  # GET /users 
  def index
    respond_with @users
  end

  # GET /users/:id
  def show
    if user_signed_in? and @user.id == current_user.id or current_user.admin?
      @listings = @user.listings
    else
      @listings = @user.listings.available
    end

    @listings = @listings.order(Listing::DEFAULT_ORDER).page(params[:page])
    respond_with @user
  end

  # GET /users/:id/edit
  def edit
    respond_with @user
  end

  # POST /users/:id
  def update
    if params[:user][:password]
      if @user.update_with_password(params[:user])
        sign_in(@user, bypass: true)
        flash[:notice] = 'User and password successfully updated'
        respond_with @user, :status => :ok, :location => user_path(@user)
      else
        render :edit
      end
    elsif @user.update_attributes params[:user]
      flash[:notice] = 'User successfully updated'
      respond_with @user, :status => :ok, :location => user_path(@user)
    else
      respond_with @category.errors, :status => :unprocessable_entity do |format|
        format.html do
          render :action => :new
        end
      end
    end
  end
  
  # GET /users/:id/update_roles
  def update_roles
    @user.toggle_role params[:role]
    if @user.save
      respond_to do |format|
        format.html {
          flash[:notice] = 'Updated permissions successfully'
          redirect_to users_path
        }
        format.json { render :json => { :status => :ok, :message => @user.roles } }
      end
    end
  end
  
  # GET /users/:id/lock
  def lock
    if @user.toggle_lock
      respond_to do |format|
        format.html {
          flash[:notice] = 'Toggled user lock successfully'
          redirect_to users_path
        }
        format.json { render :json => { :status => :ok, :message => @user.access_locked? } }
      end
    end
  end
end<commit_msg>Whoops, need user#show to be public<commit_after>class UsersController < ApplicationController
  load_resource :find_by => :permalink
  authorize_resource
  respond_to :html, :json
 
  # GET /users 
  def index
    respond_with @users
  end

  # GET /users/:id
  def show
    if user_signed_in? and (@user.id == current_user.id or current_user.admin?)
      @listings = @user.listings
    else
      @listings = @user.listings.available
    end

    @listings = @listings.order(Listing::DEFAULT_ORDER).page(params[:page])
    respond_with @user
  end

  # GET /users/:id/edit
  def edit
    respond_with @user
  end

  # POST /users/:id
  def update
    if params[:user][:password]
      if @user.update_with_password(params[:user])
        sign_in(@user, bypass: true)
        flash[:notice] = 'User and password successfully updated'
        respond_with @user, :status => :ok, :location => user_path(@user)
      else
        render :edit
      end
    elsif @user.update_attributes params[:user]
      flash[:notice] = 'User successfully updated'
      respond_with @user, :status => :ok, :location => user_path(@user)
    else
      respond_with @category.errors, :status => :unprocessable_entity do |format|
        format.html do
          render :action => :new
        end
      end
    end
  end
  
  # GET /users/:id/update_roles
  def update_roles
    @user.toggle_role params[:role]
    if @user.save
      respond_to do |format|
        format.html {
          flash[:notice] = 'Updated permissions successfully'
          redirect_to users_path
        }
        format.json { render :json => { :status => :ok, :message => @user.roles } }
      end
    end
  end
  
  # GET /users/:id/lock
  def lock
    if @user.toggle_lock
      respond_to do |format|
        format.html {
          flash[:notice] = 'Toggled user lock successfully'
          redirect_to users_path
        }
        format.json { render :json => { :status => :ok, :message => @user.access_locked? } }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10783824263604593, 'fraction_numerical': 0.0, 'mean_word_length': 2.466262975778547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4104922', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1243, 'n_words': 320}