Add option to allow empty password or not (closes #577)

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2025-03-06 22:00:46 +01:00
parent 6504cd0209
commit 92845268af
21 changed files with 33 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ const Input = enums.Input;
const ViMode = enums.ViMode;
const Bigclock = enums.Bigclock;
allow_empty_password: bool = true,
animation: Animation = .none,
animation_timeout_sec: u12 = 0,
asterisk: ?u32 = '*',

View File

@@ -15,6 +15,7 @@ err_config: []const u8 = "unable to parse config file",
err_console_dev: []const u8 = "failed to access console",
err_dgn_oob: []const u8 = "log message",
err_domain: []const u8 = "invalid domain",
err_empty_password: []const u8 = "empty password not allowed",
err_envlist: []const u8 = "failed to get envlist",
err_hostname: []const u8 = "failed to get hostname",
err_mlock: []const u8 = "failed to lock password memory",

View File

@@ -686,7 +686,17 @@ pub fn main() !void {
update = true;
},
termbox.TB_KEY_ENTER => {
termbox.TB_KEY_ENTER => authenticate: {
if (!config.allow_empty_password and password.text.items.len == 0) {
try info_line.addMessage(lang.err_empty_password, config.error_bg, config.error_fg);
InfoLine.clearRendered(allocator, buffer) catch {
try info_line.addMessage(lang.err_alloc, config.error_bg, config.error_fg);
};
info_line.label.draw();
_ = termbox.tb_present();
break :authenticate;
}
try info_line.addMessage(lang.authenticating, config.bg, config.fg);
InfoLine.clearRendered(allocator, buffer) catch {
try info_line.addMessage(lang.err_alloc, config.error_bg, config.error_fg);