title: Need help with custom authentication
body: <p>Hey guys I created some custom authentication thanks to railscasts.com but I'm somewhat stuck as I need to restrict my users from editing other users' profiles.</p>
  
  <p>Here's my authenticate_user and current_user methods:</p>
  
  <pre><code>private
  
  def current_user
    @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
  end
  
  def authenticate_user!
    if current_user.nil?
      redirect_to login_url, :alert =&gt; "You must first log in to access this page"
    end
  end
  </code></pre>
  
  <p>Here's the before_filter in my <strong>UsersController</strong>: </p>
  
  <pre><code>before_filter :authenticate_user!, :only =&gt; [:edit, :update, :destroy]`
  </code></pre>
  
  <p><strong>EDIT:</strong> Fixed it thanks to alock27.</p>
  
  <p>I had to edit my users_controller and modify the edit action as follows:<br></p>
  
  <pre><code>@user = User.find(params[:id]    
  redirect_to root_url unless current_user == @user    
  </code></pre>