From e6aae167f2c650028e702f933a85b44be03f5de0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 9 Jul 2017 19:03:10 +0200 Subject: account: move password prompt to module --- modules/account/account.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'modules/account') diff --git a/modules/account/account.c b/modules/account/account.c index ea9d819..c972908 100644 --- a/modules/account/account.c +++ b/modules/account/account.c @@ -109,11 +109,41 @@ static int account_write_template(const char *file) static int line_handler(const struct pl *addr, void *arg) { char buf[512]; + struct ua *ua; + struct account *acc; + int err; (void)arg; (void)pl_strcpy(addr, buf, sizeof(buf)); - return ua_alloc(NULL, buf); + err = ua_alloc(&ua, buf); + if (err) + return err; + + acc = ua_account(ua); + if (!acc) { + warning("account: no account for this ua\n"); + return ENOENT; + } + + /* optional password prompt */ + if (!str_isset(account_auth_pass(acc))) { + char *pass = NULL; + + (void)re_printf("Please enter password for %s: ", + account_aor(acc)); + + err = ui_password_prompt(&pass); + if (err) + goto out; + + err = account_set_auth_pass(acc, pass); + + mem_deref(pass); + } + + out: + return err; } -- cgit v1.2.3