6 * Display the OpenIDs associated with an account
8 void display_openids(void)
14 output_headers(1, 1, 1, 0, 0, 0);
16 do_template("beginbox_1", NULL);
17 StrBufAppendBufPlain(WCC->WBuf, _("Manage Account/OpenID Associations"), -1, 0);
18 do_template("beginbox_2", NULL);
20 if (WCC->serv_info->serv_supports_openid) {
22 wc_printf("<table class=\"altern\">");
25 serv_getln(buf, sizeof buf);
26 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
28 wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
29 wc_printf("<td><img src=\"static/openid-small.gif\"></td><td>");
31 wc_printf("</td><td>");
32 wc_printf("<a href=\"openid_detach?id_to_detach=");
34 wc_printf("\" onClick=\"return confirm('%s');\">",
35 _("Do you really want to delete this OpenID?"));
36 wc_printf("%s</a>", _("(delete)"));
37 wc_printf("</td></tr>\n");
40 wc_printf("</table><br />\n");
42 wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
43 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
44 wc_printf(_("Add an OpenID: "));
45 wc_printf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
46 wc_printf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
47 "</form></center>\n", _("Attach"));
51 wc_printf(_("%s does not permit authentication via OpenID."), ChrPtr(WCC->serv_info->serv_humannode));
54 do_template("endbox", NULL);
60 * Attempt to attach an OpenID to an existing, logged-in account
62 void openid_attach(void) {
65 if (havebstr("attach_button")) {
67 lprintf(CTDL_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
69 snprintf(buf, sizeof buf,
70 "OIDS %s|%s/finalize_openid_login|%s",
77 serv_getln(buf, sizeof buf);
79 lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
80 http_redirect(&buf[4]);
84 lprintf(CTDL_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
88 /* If we get to this point then something failed. */
94 * Detach an OpenID from the currently logged-in account
96 void openid_detach(void) {
99 if (havebstr("id_to_detach")) {
100 serv_printf("OIDD %s", bstr("id_to_detach"));
101 serv_getln(buf, sizeof buf);
103 strcpy(WC->ImportantMessage, &buf[4]);
114 WebcitAddUrlHandler(HKEY("display_openids"), "", 0, display_openids, 0);
115 WebcitAddUrlHandler(HKEY("openid_attach"), "", 0, openid_attach, 0);
116 WebcitAddUrlHandler(HKEY("openid_detach"), "", 0, openid_detach, 0);