1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-16 05:34:49 +00:00
opus/sys/apps/system/password.lua

46 lines
1.2 KiB
Lua
Raw Normal View History

local Security = require('opus.security')
local SHA = require('opus.crypto.sha2')
local UI = require('opus.ui')
2018-12-23 03:11:16 +00:00
return UI.Tab {
2020-04-27 01:39:58 +00:00
title = 'Password',
2018-12-23 03:11:16 +00:00
description = 'Wireless network password',
[1] = UI.Window {
x = 2, y = 2, ex = -2, ey = 4,
},
2018-12-23 03:11:16 +00:00
newPass = UI.TextEntry {
x = 3, ex = -3, y = 3,
2018-12-23 03:11:16 +00:00
limit = 32,
mask = true,
shadowText = 'new password',
accelerators = {
enter = 'new_password',
},
},
button = UI.Button {
x = -8, ex = -2, y = -2,
text = 'Apply',
2018-12-23 03:11:16 +00:00
event = 'update_password',
},
info = UI.TextArea {
x = 2, ex = -2, y = 5, ey = -4,
backgroundColor = 'black',
textColor = 'yellow',
2018-12-23 03:11:16 +00:00
inactive = true,
marginLeft = 1, marginRight = 1, marginTop = 1,
2018-12-23 03:11:16 +00:00
value = 'Add a password to enable other computers to connect to this one.',
},
eventHandler = function(self, event)
if event.type == 'update_password' then
if not self.newPass.value or #self.newPass.value == 0 then
self:emit({ type = 'error_message', message = 'Invalid password' })
2018-12-23 03:11:16 +00:00
else
Security.updatePassword(SHA.compute(self.newPass.value))
self:emit({ type = 'success_message', message = 'Password updated' })
end
return true
2018-12-23 03:11:16 +00:00
end
end
}