redmine_remotes 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0671e339c9e225c9413feb402fed23e0ac5e930a3e72027aa2b183749441d5
|
4
|
+
data.tar.gz: eb1245a9f15262922b95bec5574bdbb3dbc84f286d7fed371970b759657f6e2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0af87885a31cc69c7ec0cc8f1bbd7201b189b8c5f260382d990189affb7ab642b5eba050231e3e7c0a78f5d65a134c21490148d5461858c61af9ad92c813e578
|
7
|
+
data.tar.gz: 322120abe8ba4dde501c3d6cccc3a3315933d18f585d4c7eb9a86b8c147ec797c0dcb2bff8b08ac29001466eb12e2824cb29a1ef7394b5db1d8f21cbe4c31778
|
data/app/models/remote_user.rb
CHANGED
@@ -11,18 +11,7 @@ class RemoteUser < ActiveRecord::Base
|
|
11
11
|
validates :remote_login, presence: true, uniqueness: { scope: [:remote_tracker] }
|
12
12
|
validates :local_user, presence: true
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
[remote_tracker, nil].each do |tracker|
|
17
|
-
remote_user = ::RemoteUser.where(
|
18
|
-
remote_tracker: tracker,
|
19
|
-
remote_login: remote_login_sanitize(remote_login)
|
20
|
-
).first
|
21
|
-
return remote_user.local_user if remote_user
|
22
|
-
end
|
23
|
-
return remote_tracker.default_local_user if remote_tracker.present?
|
24
|
-
|
25
|
-
nil
|
26
|
-
end
|
14
|
+
def self.find_local_user(remote_login, remote_tracker = nil, register_not_found = false)
|
15
|
+
::RemoteUser::FindLocalUser.new(remote_login, remote_tracker, register_not_found).result
|
27
16
|
end
|
28
17
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
class RemoteUser < ActiveRecord::Base
|
6
|
+
class FindLocalUser
|
7
|
+
common_constructor :remote_login, :remote_tracker, :register_not_found do
|
8
|
+
self.remote_login = ::RemoteUser.remote_login_sanitize(remote_login)
|
9
|
+
end
|
10
|
+
|
11
|
+
def result
|
12
|
+
result_by_local_user || result_by_remote_user || result_by_register_not_found ||
|
13
|
+
result_by_remote_tracker_default
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def result_by_local_user
|
19
|
+
result_by_local_user_login || result_by_local_user_mail_address
|
20
|
+
end
|
21
|
+
|
22
|
+
def result_by_local_user_login
|
23
|
+
::User.find_by(login: remote_login)
|
24
|
+
end
|
25
|
+
|
26
|
+
def result_by_local_user_mail_address
|
27
|
+
condition = ::EmailAddress.arel_table[:address].matches("#{remote_login}@%")
|
28
|
+
::EmailAddress.where(condition).first.try(:user)
|
29
|
+
end
|
30
|
+
|
31
|
+
def result_by_register_not_found
|
32
|
+
return nil unless register_not_found
|
33
|
+
return nil if remote_tracker.blank?
|
34
|
+
|
35
|
+
::RemoteUser.create!(remote_login: remote_login, remote_tracker: remote_tracker,
|
36
|
+
local_user: remote_tracker.default_local_user).local_user
|
37
|
+
end
|
38
|
+
|
39
|
+
def result_by_remote_user
|
40
|
+
remote_trackers_to_search
|
41
|
+
.map { |tracker| remote_tracker_result(tracker) }
|
42
|
+
.find(&:present?)
|
43
|
+
end
|
44
|
+
|
45
|
+
def result_by_remote_tracker_default
|
46
|
+
remote_tracker.try(:default_local_user)
|
47
|
+
end
|
48
|
+
|
49
|
+
def remote_tracker_result(remote_tracker)
|
50
|
+
::RemoteUser.where(
|
51
|
+
remote_tracker: remote_tracker,
|
52
|
+
remote_login: remote_login
|
53
|
+
).first.try(:local_user)
|
54
|
+
end
|
55
|
+
|
56
|
+
def remote_trackers_to_search
|
57
|
+
remote_tracker.if_present([]) { |v| [v] } + [nil]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_remotes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Henrique Bogoni
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- app/models/remote_tracker/remote.rb
|
143
143
|
- app/models/remote_tracker_setting.rb
|
144
144
|
- app/models/remote_user.rb
|
145
|
+
- app/models/remote_user/find_local_user.rb
|
145
146
|
- app/views/project_remote_issues/_issues.html.erb
|
146
147
|
- app/views/project_remote_issues/_trackers.html.erb
|
147
148
|
- app/views/project_remote_issues/index.html.erb
|