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: passwords_controller.rb
    path of file: ./repos/gitlabhq/app/controllers/user_settings
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module UserSettings
  class PasswordsController < ApplicationController
    include Gitlab::Tracking::Helpers::WeakPasswordErrorEvent

    skip_before_action :check_password_expiration, only: [:new, :create]
    skip_before_action :check_two_factor_require
    
    def edit; end

    def update
      unless @user.password_automatically_set || @user.valid_password?(user_params[:password])
        handle_invalid_current_password_attempt!

        redirect_to edit_user_settings_password_path, alert: _('You must provide a valid current password')
        return
      end

      result = Users::UpdateService.new(current_user, password_attributes.merge(user: @user)).execute

      if result[:status] == :success
        flash[:notice] = _('Password was successfully updated. Please sign in again.')
        redirect_to new_user_session_path
      else
        track_weak_password_error(@user, self.class.name, 'update')
        @user.reset
        render 'edit'
      end