From: Art Cancro Date: Mon, 20 Jul 2009 17:01:07 +0000 (+0000) Subject: * Added a command OIDA to dump all OpenID associations X-Git-Tag: v7.86~972 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=ee68cef8ea342e0efa539e476117b44a48a1e3fa * Added a command OIDA to dump all OpenID associations --- diff --git a/citadel/modules/openid/serv_openid_rp.c b/citadel/modules/openid/serv_openid_rp.c index d6bdedf07..2429a2670 100644 --- a/citadel/modules/openid/serv_openid_rp.c +++ b/citadel/modules/openid/serv_openid_rp.c @@ -185,6 +185,31 @@ void cmd_oidl(char *argbuf) { } +/* + * List ALL OpenIDs in the database + */ +void cmd_oida(char *argbuf) { + struct cdbdata *cdboi; + long usernum; + + if (CtdlAccessCheck(ac_aide)) return; + cdb_rewind(CDB_OPENID); + cprintf("%d List of all OpenIDs in the database:\n", LISTING_FOLLOWS); + + while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) { + if (cdboi->len > sizeof(long)) { + memcpy(&usernum, cdboi->ptr, sizeof(long)); + cprintf("%s|%ld\n", + cdboi->ptr + sizeof(long), + usernum + ); + } + cdb_free(cdboi); + } + cprintf("000\n"); +} + + /* * Attempt to register (populate the vCard) the currently-logged-in user * using the data from Simple Registration Extension, if present. @@ -274,6 +299,11 @@ void populate_vcard_from_sreg(HashList *sreg_keys) { void cmd_oidc(char *argbuf) { struct ctdl_openid *oiddata = (struct ctdl_openid *) CC->openid_data; + if (!oiddata) { + cprintf("%d You have not verified an OpenID yet.\n", ERROR); + return; + } + if (!oiddata->verified) { cprintf("%d You have not verified an OpenID yet.\n", ERROR); return; @@ -903,6 +933,7 @@ CTDL_MODULE_INIT(openid_rp) 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 new user after validating OpenID"); + CtdlRegisterProtoHook(cmd_oida, "OIDA", "List all OpenIDs in the database"); } CtdlRegisterSessionHook(openid_cleanup_function, EVT_LOGOUT); CtdlRegisterUserHook(openid_purge, EVT_PURGEUSER);