summaryrefslogtreecommitdiff
path: root/modules/account/account.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-07-09 19:03:10 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-07-09 19:03:10 +0200
commite6aae167f2c650028e702f933a85b44be03f5de0 (patch)
treecdb0c099da6e913e835f0dd3f5efe61ceae324f4 /modules/account/account.c
parent40c4d6517707cee05fe0f2cfa3efc76bac962f29 (diff)
account: move password prompt to module
Diffstat (limited to 'modules/account/account.c')
-rw-r--r--modules/account/account.c32
1 files changed, 31 insertions, 1 deletions
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;
}