9 * Display the OpenIDs associated with an account
11 void display_openids(void)
16 output_headers(1, 1, 1, 0, 0, 0);
18 wprintf("<div class=\"fix_scrollbar_bug\">");
20 svput("BOXTITLE", WCS_STRING
, _("Manage Account/OpenID Associations"));
21 do_template("beginboxx", NULL
);
23 if (serv_info
.serv_supports_openid
) {
25 wprintf("<table class=\"altern\">");
28 serv_getln(buf
, sizeof buf
);
29 if (buf
[0] == '1') while (serv_getln(buf
, sizeof buf
), strcmp(buf
, "000")) {
31 wprintf("<tr class=\"%s\">", (bg
? "even" : "odd"));
32 wprintf("<td><img src=\"static/openid-small.gif\"></td><td>");
35 wprintf("<a href=\"openid_detach?id_to_detach=");
37 wprintf("\" onClick=\"return confirm('%s');\">",
38 _("Do you really want to delete this OpenID?"));
39 wprintf("%s</a>", _("(delete)"));
40 wprintf("</td></tr>\n");
43 wprintf("</table><br />\n");
45 wprintf("<form method=\"POST\" action=\"openid_attach\">\n");
46 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC
->nonce
);
47 wprintf(_("Add an OpenID: "));
48 wprintf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
49 wprintf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
50 "</form></center>\n", _("Attach"));
54 wprintf(_("%s does not permit authentication via OpenID."), ChrPtr(serv_info
.serv_humannode
));
57 do_template("endbox", NULL
);
64 * Attempt to attach an OpenID to an existing, logged-in account
66 void openid_attach(void) {
69 if (havebstr("attach_button")) {
70 lprintf(CTDL_DEBUG
, "Attempting to attach %s\n", bstr("openid_url"));
72 snprintf(buf
, sizeof buf
,
73 "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
75 (is_https
? "https" : "http"), WC
->http_host
,
76 (is_https
? "https" : "http"), WC
->http_host
80 serv_getln(buf
, sizeof buf
);
82 lprintf(CTDL_DEBUG
, "OpenID server contacted; redirecting to %s\n", &buf
[4]);
83 http_redirect(&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"), display_openids
, 0);
115 WebcitAddUrlHandler(HKEY("openid_attach"), openid_attach
, 0);
116 WebcitAddUrlHandler(HKEY("openid_detach"), openid_detach
, 0);