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

identity_linker.rb « atlassian « auth « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4dec54d44d6d536ffcf2de239d8edb5da4250903 (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
30
# frozen_string_literal: true

module Gitlab
  module Auth
    module Atlassian
      class IdentityLinker < OmniauthIdentityLinkerBase
        extend ::Gitlab::Utils::Override
        include ::Gitlab::Utils::StrongMemoize

        private

        override :identity
        def identity
          strong_memoize(:identity) do
            current_user.atlassian_identity || build_atlassian_identity
          end
        end

        def build_atlassian_identity
          identity = current_user.build_atlassian_identity
          ::Gitlab::Auth::Atlassian::User.assign_identity_from_auth_hash!(identity, auth_hash)
        end

        def auth_hash
          ::Gitlab::Auth::Atlassian::AuthHash.new(oauth)
        end
      end
    end
  end
end