9 * Display the OpenIDs associated with an account
11 void display_openids(void)
17 output_headers(1, 1, 1, 0, 0, 0);
19 wc_printf("<div class=\"fix_scrollbar_bug\">");
21 do_template("beginbox_1", NULL);
22 StrBufAppendBufPlain(WCC->WBuf, _("Manage Account/OpenID Associations"), -1, 0);
23 do_template("beginbox_2", NULL);
25 if (WCC->serv_info->serv_supports_openid) {
27 wc_printf("<table class=\"altern\">");
30 serv_getln(buf, sizeof buf);
31 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
33 wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
34 wc_printf("<td><img src=\"static/openid-small.gif\"></td><td>");
36 wc_printf("</td><td>");
37 wc_printf("<a href=\"openid_detach?id_to_detach=");
39 wc_printf("\" onClick=\"return confirm('%s');\">",
40 _("Do you really want to delete this OpenID?"));
41 wc_printf("%s</a>", _("(delete)"));
42 wc_printf("</td></tr>\n");
45 wc_printf("</table><br />\n");
47 wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
48 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
49 wc_printf(_("Add an OpenID: "));
50 wc_printf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
51 wc_printf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
52 "</form></center>\n", _("Attach"));
56 wc_printf(_("%s does not permit authentication via OpenID."), ChrPtr(WCC->serv_info->serv_humannode));
59 do_template("endbox", NULL);
66 * Attempt to attach an OpenID to an existing, logged-in account
68 void openid_attach(void) {
71 if (havebstr("attach_button")) {
74 lprintf(CTDL_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
76 snprintf(buf, sizeof buf,
77 "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
79 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host),
80 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host)
84 serv_getln(buf, sizeof buf);
86 lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
87 http_redirect(&buf[4]);
91 lprintf(CTDL_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
95 /* If we get to this point then something failed. */
101 * Detach an OpenID from the currently logged-in account
103 void openid_detach(void) {
106 if (havebstr("id_to_detach")) {
107 serv_printf("OIDD %s", bstr("id_to_detach"));
108 serv_getln(buf, sizeof buf);
110 strcpy(WC->ImportantMessage, &buf[4]);
121 WebcitAddUrlHandler(HKEY("display_openids"), "", 0, display_openids, 0);
122 WebcitAddUrlHandler(HKEY("openid_attach"), "", 0, openid_attach, 0);
123 WebcitAddUrlHandler(HKEY("openid_detach"), "", 0, openid_detach, 0);