Update settings.lua

This commit is contained in:
Ale32bit 2016-11-02 21:02:44 +01:00 committed by GitHub
parent 6bbcf55c39
commit 980a5d826e

View file

@ -29,9 +29,7 @@ local function changeUsername()
write("Username: ") write("Username: ")
local newUsername = read() local newUsername = read()
sPhone.user = newUsername sPhone.user = newUsername
f = fs.open("/.sPhone/config/username","w") config.write("/.sPhone/config/sPhone","username",newUsername)
f.write(sPhone.user)
f.close()
sPhone.winOk("Username","Changed") sPhone.winOk("Username","Changed")
end end
@ -59,8 +57,8 @@ local function changePassword()
term.setTextColor(sPhone.theme["text"]) term.setTextColor(sPhone.theme["text"])
local password = read("*") local password = read("*")
term.redirect(sPhone.mainTerm) term.redirect(sPhone.mainTerm)
local fpw = fs.open("/.sPhone/config/.password","r") local fpw = config.read("/.sPhone/config/sPhone","password")
if sha256.sha256(password) ~= fpw.readLine() then if sha256.sha256(password) ~= fpw then
sPhone.wrongPassword = true sPhone.wrongPassword = true
else else
sPhone.wrongPassword = false sPhone.wrongPassword = false
@ -119,9 +117,7 @@ local function changePassword()
end end
end end
if not sPhone.wrongPassword then if not sPhone.wrongPassword then
local f = fs.open("/.sPhone/config/.password","w") config.write("/.sPhone/config/sPhone","password",sha256.sha256(pwChangeRep))
f.write(sha256.sha256(pwChangeRep))
f.close()
end end
sPhone.header(sPhone.user) sPhone.header(sPhone.user)
visum.align("center", "All Set!", false, 3) visum.align("center", "All Set!", false, 3)