Skip to content

Commit 3658a2a

Browse files
committed
Modify ldap_username to be correct in api and make rubocop happy
1 parent 44b2782 commit 3658a2a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/domain/ptime/people_employees.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def person_role_level_id_by_role(role)
114114
end
115115

116116
def update_person_with_auth_user_id
117-
ldap_username = @ptime_employee_attributes[:ldap_username]
117+
ldap_username = @ptime_employee_attributes[:ldapname]
118118
@person.auth_user_id = AuthUser.find_by(ldap_username:)&.id
119119
end
120120
end

app/models/auth_user.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ class AuthUser < ApplicationRecord
66

77
class << self
88
def from_omniauth(auth)
9-
person = where(uid: auth.uid).first_or_create do |user|
10-
user.name = auth.info.name
11-
user.email = auth.info.email
12-
user.ldap_username = auth.extra.raw_info.pitc.uid
13-
end
9+
person = where(uid: auth.uid).first_or_create { |user| initialize_user(user, auth) }
1410
person.last_login = Time.zone.now
1511
set_admin(person, auth)
1612
end
1713

1814
private
1915

16+
def initialize_user(user, auth)
17+
user.name = auth.info.name
18+
user.email = auth.info.email
19+
user.ldap_username = auth.extra.raw_info.pitc.uid
20+
end
21+
2022
def set_admin(person, auth)
2123
person.is_admin = role?(auth, AuthConfig.admin_role)
2224
person.is_conf_admin = role?(auth, AuthConfig.conf_admin_role)

0 commit comments

Comments
 (0)