changeset 1382:9604579c1c9b

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 29 Jul 2019 09:50:14 -0600
parents 8d7a39ca2c0c
children a3d0d1c2ce89
files src/luan/host/Util.luan
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/host/Util.luan	Sun Jul 28 20:15:38 2019 -0600
+++ b/src/luan/host/Util.luan	Mon Jul 29 09:50:14 2019 -0600
@@ -26,7 +26,9 @@
 local function basic_authentication(dir,password)
 	local sha1 = MessageDigest.getInstance("SHA1").digest(password.getBytes())
 	local encoded = Base64.getEncoder().encodeToString(sha1)
-	Io.schemes.file(dir.."/password.nginx").write_text( %>
+	local file = Io.schemes.file(dir.."/password.nginx")
+	file.delete()
+	file.write_text( %>
 admin:{SHA}<%=encoded%>
 <%	)
 end
@@ -39,14 +41,18 @@
 	for _, n in ipairs(md5) do
 		encoded = encoded..format("%02x",n)
 	end
-	Io.schemes.file(dir.."/password.nginx").write_text( %>
+	local file = Io.schemes.file(dir.."/password.nginx")
+	file.delete()
+	file.write_text( %>
 admin:Restricted:<%=encoded%>
 <%	)
 end
 
 function Util.write_password(domain,password)
 	local dir = Hosting.sites_dir..lower(domain)
-	Io.schemes.file(dir.."/info.luan").write_text( %>
+	local file = Io.schemes.file(dir.."/info.luan")
+	file.delete()
+	file.write_text( %>
 return <%= stringify{password=password} %>
 <%	)
 	digest_authentication(dir,password)