an existing Citadel account.
groupdav_main.o groupdav_get.o groupdav_propfind.o fmt_date.o \
groupdav_options.o autocompletion.o gettext.o tabs.o sieve.o \
groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \
- downloads.o addressbook_popup.o pushemail.o sysdep.o \
+ downloads.o addressbook_popup.o pushemail.o sysdep.o openid.o \
$(LIBOBJS)
$(CC) webserver.o context_loop.o cookie_conversion.o \
webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \
roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \
locate_host.o siteconfig.o subst.o vcard_edit.o floors.o \
- graphics.o netconf.o preferences.o html2html.o rss.o \
+ graphics.o netconf.o preferences.o html2html.o rss.o openid.o \
summary.o calendar.o calendar_tools.o calendar_view.o event.o wiki.o \
availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \
groupdav_main.o groupdav_get.o groupdav_propfind.o groupdav_delete.o \
{
char buf[1024];
struct wcsession *WCC = WC;
+ int already_logged_in = (WCC->logged_in) ;
if (havebstr("openid.mode")) {
if (!strcasecmp(bstr("openid.mode"), "id_res")) {
// FIXME
}
}
- else {
- display_openid_login(&buf[4]);
- return;
- }
-
}
}
+ /* If we were already logged in, this was an attempt to associate an OpenID account */
+ if (already_logged_in) {
+ display_openids();
+ return;
+ }
+
+ /* Otherwise the user is probably attempting to log in using OpenID */
if (WC->logged_in) {
if (WC->need_regi) {
display_reg(1);
wprintf("</td></tr>"
"<tr valign=top><td width=50%%>");
- print_menu_box(_("Your info"), "adminitems", 7,
+ print_menu_box(_("Your info"), "adminitems", 8,
"display_preferences", _("Change your preferences and settings"),
"display_reg", _("Update your contact information"),
"display_changepw", _("Change your password"),
"display_editbio", _("Enter your 'bio'"),
"display_editpic", _("Edit your online photo"),
"display_sieve", _("View/edit server-side mail filters"),
- "display_pushemail", _("Edit your push email settings"));
+ "display_pushemail", _("Edit your push email settings"),
+ "display_openids", _("Manage your OpenIDs")
+ );
wprintf("</td><td width=50%%>");
--- /dev/null
+/*
+ * $Id$
+ */
+
+#include "webcit.h"
+#include "webserver.h"
+
+/*
+ * Display the OpenIDs associated with an account
+ */
+void display_openids(void)
+{
+ output_headers(1, 1, 1, 0, 0, 0);
+
+ wprintf("<div class=\"fix_scrollbar_bug\">");
+
+ svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations"));
+ do_template("beginbox");
+
+ wprintf("FIXME -- we have to list the existing ones here");
+
+ wprintf("<hr>\n");
+
+ wprintf("<form method=\"POST\" action=\"openid_attach\">\n");
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+ wprintf(_("Add an OpenID: "));
+ wprintf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
+ wprintf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
+ "</form></center>\n", _("Attach"));
+ do_template("endbox");
+ wprintf("</div>");
+ wDumpContent(2);
+}
+
+
+/*
+ * Attempt to attach an OpenID to an existing, logged-in account
+ */
+void openid_attach(void) {
+ char buf[4096];
+
+ if (havebstr("attach_button")) {
+ lprintf(CTDL_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"), WC->http_host,
+ (is_https ? "https" : "http"), WC->http_host
+ );
+
+ serv_puts(buf);
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '2') {
+ lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
+ http_redirect(&buf[4]);
+ return;
+ }
+ }
+
+ /* If we get to this point then something failed. */
+ display_openids();
+}
+
+
display_openid_login(NULL);
} else if ((!WC->logged_in) && (!strcasecmp(action, "openid_login"))) {
do_openid_login();
- } else if ((!WC->logged_in) && (!strcasecmp(action, "finalize_openid_login"))) {
+ } else if (!strcasecmp(action, "finalize_openid_login")) {
finalize_openid_login();
} else if (!WC->logged_in) {
display_login(NULL);
download_file(index[1]);
} else if (!strcasecmp(action, "upload_file")) {
upload_file();
+ } else if (!strcasecmp(action, "display_openids")) {
+ display_openids();
+ } else if (!strcasecmp(action, "openid_attach")) {
+ openid_attach();
}
/** When all else fais, display the main menu. */
void finalize_openid_login(void);
void display_login(char *mesg);
void display_openid_login(char *mesg);
+void display_openids(void);
+void openid_attach(void);
void do_welcome(void);
void do_logout(void);
void display_main_menu(void);