Commit e9aa84799a6417d9404dc72599d04b205d8ff98b

Patrick Steinhardt 2019-04-16T10:52:47

examples: support plain username credentials Implement plain username credential types. These type of credentials might be asked for e.g. as some kind of pre-authentication step, before the actual credentials are passed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/examples/common.c b/examples/common.c
index ee47107..aae9f97 100644
--- a/examples/common.c
+++ b/examples/common.c
@@ -362,6 +362,11 @@ int cred_acquire_cb(git_cred **out,
 			goto out;
 
 		error = git_cred_userpass_plaintext_new(out, username, password);
+	} else if (allowed_types & GIT_CREDTYPE_USERNAME) {
+		if ((error = ask(&username, "Username:")) < 0)
+			goto out;
+
+		error = git_cred_username_new(out, username);
 	}
 
 out: