Sha256: 8075521297a2ff7e6d4f253a03a5a5d320981a7a9a55bf407f8c498b2f78df11

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module Match
  class ChangePassword
    def self.update(params: nil, from: nil, to: nil)
      to ||= ChangePassword.ask_password(message: "New passphrase for Git Repo: ", confirm: false)
      from ||= ChangePassword.ask_password(message: "Old passphrase for Git Repo: ", confirm: true)
      GitHelper.clear_changes
      workspace = GitHelper.clone(params[:git_url], params[:shallow_clone], manual_password: from, skip_docs: params[:skip_docs], branch: params[:git_branch])
      Encrypt.new.clear_password(params[:git_url])
      Encrypt.new.store_password(params[:git_url], to)

      message = "[fastlane] Changed passphrase"
      GitHelper.commit_changes(workspace, message, params[:git_url], params[:git_branch])
    end

    def self.ask_password(message: "Passphrase for Git Repo: ", confirm: true)
      loop do
        password = ask(message.yellow) { |q| q.echo = "*" }
        if confirm
          password2 = ask("Type passphrase again: ".yellow) { |q| q.echo = "*" }
          if password == password2
            return password
          end
        else
          return password
        end
        UI.error("Passhprases differ. Try again")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
match-0.6.3 lib/match/change_password.rb
match-0.6.2 lib/match/change_password.rb
match-0.6.1 lib/match/change_password.rb
match-0.6.0 lib/match/change_password.rb