You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: emails_controller.rb
    path of file: ./repos/rubyvideo/app/controllers/identity
    
    the code of the file until where you have to start completion: class Identit
    
  def update
    if !@user.authenticate(params[:current_password])
      redirect_to edit_identity_email_path, alert: "The password you entered is incorrect"
    elsif @user.update(email: params[:email])
      redirect_to_root
    else
      render :edit, status: :unprocessable_entity
    end