final touches on dkim test harness
[citadel.git] / webcit / openid.c
index b489a55c484af1ba6124e4aefb31bb6e7b244e68..b56c01c2418b82e8ba2812dde0467062598a54b7 100644 (file)
@@ -1,9 +1,17 @@
 /*
- * $Id$
+ * Copyright (c) 1996-2012 by the citadel.org team
+ *
+ * This program is open source software.  You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "webcit.h"
-#include "webserver.h"
+
 
 /*
  * Display the OpenIDs associated with an account
@@ -16,10 +24,9 @@ void display_openids(void)
 
        output_headers(1, 1, 1, 0, 0, 0);
 
-       wc_printf("<div class=\"fix_scrollbar_bug\">");
-
-       svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations"));
-       do_template("beginboxx", NULL);
+       do_template("box_begin_1");
+       StrBufAppendBufPlain(WCC->WBuf, _("Manage Account/OpenID Associations"), -1, 0);
+       do_template("box_begin_2");
 
        if (WCC->serv_info->serv_supports_openid) {
 
@@ -30,7 +37,7 @@ void display_openids(void)
                if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                        bg = 1 - bg;
                        wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
-                       wc_printf("<td><img src=\"static/openid-small.gif\"></td><td>");
+                       wc_printf("<td><img src=\"static/webcit_icons/openid-small.gif\"></td><td>");
                        escputs(buf);
                        wc_printf("</td><td>");
                        wc_printf("<a href=\"openid_detach?id_to_detach=");
@@ -41,7 +48,7 @@ void display_openids(void)
                        wc_printf("</td></tr>\n");
                }
        
-               wc_printf("</table><br />\n");
+               wc_printf("</table><br>\n");
        
                wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
                wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
@@ -55,8 +62,7 @@ void display_openids(void)
                wc_printf(_("%s does not permit authentication via OpenID."), ChrPtr(WCC->serv_info->serv_humannode));
        }
 
-       do_template("endbox", NULL);
-       wc_printf("</div>");
+       do_template("box_end");
        wDumpContent(2);
 }
 
@@ -68,26 +74,25 @@ void openid_attach(void) {
        char buf[4096];
 
        if (havebstr("attach_button")) {
-               wcsession *WCC = WC;
 
-               lprintf(CTDL_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
+               syslog(LOG_DEBUG, "Attempting to attach %s\n", bstr("openid_url"));
 
                snprintf(buf, sizeof buf,
-                        "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
-                        bstr("openid_url"),
-                        (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host),
-                        (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host)
+                       "OIDS %s|%s/finalize_openid_login?attach_existing=1|%s",
+                       bstr("openid_url"),
+                       ChrPtr(site_prefix),
+                       ChrPtr(site_prefix)
                );
 
                serv_puts(buf);
                serv_getln(buf, sizeof buf);
                if (buf[0] == '2') {
-                       lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
+                       syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
                        http_redirect(&buf[4]);
                        return;
                }
                else {
-                       lprintf(CTDL_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
+                       syslog(LOG_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
                }
        }
 
@@ -100,14 +105,14 @@ void openid_attach(void) {
  * Detach an OpenID from the currently logged-in account
  */
 void openid_detach(void) {
-       char buf[1024];
+       StrBuf *Line;
 
        if (havebstr("id_to_detach")) {
                serv_printf("OIDD %s", bstr("id_to_detach"));
-               serv_getln(buf, sizeof buf);
-               if (buf[0] != '2') {
-                       strcpy(WC->ImportantMessage, &buf[4]);
-               }
+               Line = NewStrBuf();
+               StrBuf_ServGetln(Line);
+               GetServerStatusMsg(Line, NULL, 1, 2);
+               FreeStrBuf(&Line);
        }
 
        display_openids();