diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-11-11 20:07:32 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-11-11 20:07:32 +0000 |
commit | 63c4b0abf1bfb922d6497a816108c35b971a1d2d (patch) | |
tree | 090b628ba17b95cd62909d4fd88fd8b08b100e90 /lib | |
parent | d3a17ed2c3fabf376f8752d53729a2352e83b45c (diff) | |
download | acf-core-63c4b0abf1bfb922d6497a816108c35b971a1d2d.tar.bz2 acf-core-63c4b0abf1bfb922d6497a816108c35b971a1d2d.tar.xz |
Fixed bug in authenticator-plaintext that erased user data from other fields when saving user data.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1594 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/authenticator-plaintext.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua index 73438e3..ad6c632 100644 --- a/lib/authenticator-plaintext.lua +++ b/lib/authenticator-plaintext.lua @@ -61,14 +61,20 @@ write_entry = function(self, tabl, field, id, entry) if not self or not tabl or tabl == "" or not field or not id or not entry then return false end - delete_entry(self, tabl, field, id) -- Set path to passwordfile local passwd_path = self.conf.confdir .. field .. tabl -- Write the newline into the file if fs.is_file(passwd_path) == false then fs.create_file(passwd_path) end if fs.is_file(passwd_path) == false then return false end - fs.write_line_file(passwd_path, id .. ":" .. entry) + local passwdfilecontent = fs.read_file_as_array(passwd_path) or {} + local output = {id .. ":" .. entry} + for k,v in pairs(passwdfilecontent) do + if not ( string.match(v, "^".. id .. "[:=]") ) and not string.match(v, "^%s*$") then + table.insert(output, v) + end + end + fs.write_file(passwd_path, table.concat(output, "\n")) return true end |