Skip to content

Commit

Permalink
chages from review
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Sep 20, 2021
1 parent 014b4e5 commit f0a34e7
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/lib/y2users/users_module/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ class Reader
def read
Config.new.tap do |config|
read_elements(config)
config.login = read_autologin
config.useradd = read_useradd_defaults
read_autologin(config)
read_useradd_defaults(config)
end
end

private

# Reads the useradd defaults from Users module
#
# @param config [Config]
# @return [UseraddConfig]
def read_useradd_defaults
users_map = Yast::Users.GetLoginDefaults
# notes: groups are deprecated and usrskell and create_mail_spool is not in users
# notes: groups are deprecated and usrskel and create_mail_spool is not in users
y2users_map = {
group: users_map["group"],
home: users_map["home"],
Expand All @@ -60,25 +61,23 @@ def read_useradd_defaults
shell: users_map["shell"],
skel: users_map["skel"]
}
UseraddConfig.new(y2users_map)

config.useradd = UseraddConfig.new(y2users_map)
end

# Reads the Autlogin config from Autologin module
# Reads the Autologin config from Autologin module
#
# @note Users reads and sets autologin directly and do not expose it
# @note Users reads and sets autologin directly and does not expose it
# so it is easier to read it directly
#
# @param config [Config]
# @return [LoginConfig]
def read_autologin
res = LoginConfig.new
res.autologin_user = if Yast::Autologin.user.empty?
nil
else
Yast::Autologin.user
end
res.autologin_user = Yast::Autologin.user.empty? ? nil : Yast::Autologin.user
res.passwordless = Yast::Autologin.pw_less

res
config.login = res
end

# Reads the users and groups
Expand All @@ -91,6 +90,7 @@ def read_elements(config)

# Returns the list of users
#
# @param config [Config]
# @return [Array<User>] the collection of users
def users(config)
all_local = Yast::Users.GetUsers("uid", "local").values +
Expand All @@ -107,6 +107,7 @@ def groups
# Creates a {User} object based on the data structure of a Users user
#
# @param user_attrs [Hash] a user representation in the format used by Users
# @param config [Config]
# @return [User]
def user(user_attrs, config)
user = User.new(user_attrs["uid"])
Expand Down Expand Up @@ -163,9 +164,9 @@ def attr_value(attr, user)
value
end

# Creates a {Password} object based on the data structure of a UsersSimple user
# Creates a {Password} object based on the data structure of a Users user
#
# @param user [Hash] a user representation in the format used by UsersSimple
# @param user [Hash] a user representation in the format used by Users
# @return [Password]
def create_password(user)
create_method = user["encrypted"] ? :create_encrypted : :create_plain
Expand Down

0 comments on commit f0a34e7

Please sign in to comment.