}
+/*
+ * Create a new user account, manually specifying the name, after successfully
+ * verifying an OpenID (which will of course be attached to the account)
+ */
+void cmd_oidc(char *argbuf) {
+ struct ctdl_openid *oiddata = (struct ctdl_openid *) CC->openid_data;
+
+ if (!oiddata->verified) {
+ cprintf("%d You have not verified an OpenID yet.\n", ERROR);
+ return;
+ }
+
+ /* We can make the semantics of OIDC exactly the same as NEWU, simply
+ * by _calling_ cmd_newu() and letting it run. Very clever!
+ */
+ cmd_newu(argbuf);
+
+ /* Now, if this logged us in, we have to attach the OpenID */
+ if (CC->logged_in) {
+ attach_openid(&CC->user, oiddata->claimed_id);
+ }
+}
+
+
+
/*
* Detach an OpenID from the currently logged in account
CtdlRegisterProtoHook(cmd_oidf, "OIDF", "Finalize OpenID authentication");
CtdlRegisterProtoHook(cmd_oidl, "OIDL", "List OpenIDs associated with an account");
CtdlRegisterProtoHook(cmd_oidd, "OIDD", "Detach an OpenID from an account");
+ CtdlRegisterProtoHook(cmd_oidc, "OIDC", "Create a new user after validating an OpenID");
CtdlRegisterSessionHook(openid_cleanup_function, EVT_LOGOUT);
CtdlRegisterUserHook(openid_purge, EVT_PURGEUSER);
}
/* return our Subversion id for the Log */
return "$Id$";
}
-
-
-/* FIXME ... we have to add the new openid database to serv_vandelay.c */
-
*/
void cmd_setp(char *new_pw)
{
+ int generate_random_password = 0;
+
if (CtdlAccessCheck(ac_logged_in)) {
return;
}
ERROR + NOT_HERE);
return;
}
- strproc(new_pw);
- if (IsEmptyStr(new_pw)) {
- cprintf("%d Password unchanged.\n", CIT_OK);
- return;
- }
- CtdlSetPassword(new_pw);
- cprintf("%d Password changed.\n", CIT_OK);
+ if (!strcasecmp(new_pw, "GENERATE_RANDOM_PASSWORD")) {
+ char random_password[17];
+ generate_random_password = 1;
+ snprintf(random_password, sizeof random_password, "%08lx%08lx", random(), random());
+ CtdlSetPassword(random_password);
+ cprintf("%d %s\n", CIT_OK, random_password);
+ }
+ else {
+ strproc(new_pw);
+ if (IsEmptyStr(new_pw)) {
+ cprintf("%d Password unchanged.\n", CIT_OK);
+ return;
+ }
+ CtdlSetPassword(new_pw);
+ cprintf("%d Password changed.\n", CIT_OK);
+ }
}
stresc(buf, sizeof buf, claimed_id, 0, 0);
svprintf(HKEY("VERIFIED"), WCS_STRING, _("Your OpenID <tt>%s</tt> was successfully verified."),
claimed_id);
+ svput("CLAIMED_ID", WCS_STRING, claimed_id);
+
if (!IsEmptyStr(username)) {
stresc(buf, sizeof buf, username, 0, 0);
return;
}
-#if 0
- char buf[SIZ];
+ char buf[1024];
if (havebstr("newuser_action")) {
serv_printf("OIDC %s", bstr("name"));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- become_logged_in(bstr("name"), bstr("pass"), buf); // FIXME
- } else {
- display_openid_name_request(char *claimed_id, char *username); // FIXME
- return;
+ char gpass[1024] = "";
+ serv_puts("SETP GENERATE_RANDOM_PASSWORD");
+ serv_getln(gpass, sizeof gpass);
+ become_logged_in(bstr("name"), &gpass[4], buf);
}
}
-#endif
if (WC->logged_in) {
if (WC->need_regi) {
do_welcome();
}
} else {
- display_login(_("Your password was not accepted."));
+ display_openid_name_request(bstr("openid_url"), bstr("name"));
}
}
<?ACTION_REQUESTED><br />
</div>
<form action="openid_manual_create" method="POST" class="box" id="login_form">
+ <input type="hidden" NAME="openid_url" VALUE="<?CLAIMED_ID>">
<label for="uname"><?USERNAME_BOX></label>
<input type="text" name="name" id="uname" > <br>
<div class="logbuttons">