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 svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations"));
22 do_template("beginboxx", NULL);
24 if (WCC->serv_info->serv_supports_openid) {
26 wc_printf("<table class=\"altern\">");
29 serv_getln(buf, sizeof buf);
30 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
32 wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
33 wc_printf("<td><img src=\"static/openid-small.gif\"></td><td>");
35 wc_printf("</td><td>");
36 wc_printf("<a href=\"openid_detach?id_to_detach=");
38 wc_printf("\" onClick=\"return confirm('%s');\">",
39 _("Do you really want to delete this OpenID?"));
40 wc_printf("%s</a>", _("(delete)"));
41 wc_printf("</td></tr>\n");
44 wc_printf("</table><br />\n");
46 wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
47 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
48 wc_printf(_("Add an OpenID: "));
49 wc_printf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
50 wc_printf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
51 "</form></center>\n", _("Attach"));
55 wc_printf(_("%s does not permit authentication via OpenID."), ChrPtr(WCC->serv_info->serv_humannode));
58 do_template("endbox", NULL);
65 * Attempt to attach an OpenID to an existing, logged-in account
67 void openid_attach(void) {
70 if (havebstr("attach_button")) {
73 lprintf(CTDL_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
75 snprintf(buf, sizeof buf,
76 "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
78 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host),
79 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host)
83 serv_getln(buf, sizeof buf);
85 lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
86 http_redirect(&buf[4]);
90 lprintf(CTDL_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
94 /* If we get to this point then something failed. */
100 * Detach an OpenID from the currently logged-in account
102 void openid_detach(void) {
105 if (havebstr("id_to_detach")) {
106 serv_printf("OIDD %s", bstr("id_to_detach"));
107 serv_getln(buf, sizeof buf);
109 strcpy(WC->ImportantMessage, &buf[4]);
120 WebcitAddUrlHandler(HKEY("display_openids"), "", 0, display_openids, 0);
121 WebcitAddUrlHandler(HKEY("openid_attach"), "", 0, openid_attach, 0);
122 WebcitAddUrlHandler(HKEY("openid_detach"), "", 0, openid_detach, 0);