Welcome to mirror list, hosted at ThFree Co, Russian Federation.

smtp_config.rb « email « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c9deb3fe3244eb93d5334a4b6a2758e576746b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  module Email
    class SmtpConfig
      def self.encrypted_secrets
        Settings.encrypted(Gitlab.config.gitlab.email_smtp_secret_file)
      end

      def self.secrets
        self.new
      end

      def initialize
        @secrets ||= self.class.encrypted_secrets.config
      rescue StandardError => e
        Gitlab::AppLogger.error "SMTP encrypted secrets are invalid: #{e.inspect}"
      end

      def username
        @secrets&.fetch(:user_name, nil)&.chomp
      end

      def password
        @secrets&.fetch(:password, nil)&.chomp
      end
    end
  end
end