WIP Passwd#mod_user

This commit is contained in:
Luka Vandervelden 2019-05-29 15:30:23 +02:00
parent c137bd343a
commit 8b03bc4da1
2 changed files with 21 additions and 0 deletions

View File

@ -171,6 +171,25 @@ class Passwd
File.write(@group, group.to_csv + "\n", mode: "a")
end
# FIXME: Edit other important fields.
def mod_user(uid, password_hash : String? = nil)
new_passwd = passwd_as_array.map do |line|
user = AuthD::User.new line
if uid == user.uid
password_hash.try do |hash|
user.password_hash = hash
end
user.to_csv
else
line.join(':') + "\n"
end
end
puts new_passwd.join
end
end
class AuthD::Group

View File

@ -1,4 +1,6 @@
require "json"
class AuthD::User
getter login : String
getter password_hash : String