chiark / gitweb /
Confirmation URLs now work and activate new logins. The code is all a
authorrjk@greenend.org.uk <>
Sun, 30 Dec 2007 20:56:33 +0000 (20:56 +0000)
committerrjk@greenend.org.uk <>
Sun, 30 Dec 2007 20:56:33 +0000 (20:56 +0000)
bit ad-hoc and crufty but the basic functionality does work.

server/dcgi.c
templates/login.html

index d8783305c1563b754e3387780abe2e897d99872c..e36719c558596ea1b33a038fd4188b69027b8bb2 100644 (file)
@@ -537,7 +537,7 @@ static void act_register(cgi_sink *output,
   byte_xasprintf((char **)&text,
                 "Welcome to DisOrder.  To active your login, please visit this URL:\n"
                 "\n"
-                "  %s?confirm=%s\n", config->url, confirm);
+                "  %s?confirm=%s\n", config->url, urlencodestring(confirm));
   if(!(text = mime_encode_text(text, &charset, &encoding)))
     fatal(0, "cannot encode email");
   byte_xasprintf(&content_type, "text/plain;charset=%s",
@@ -549,10 +549,27 @@ static void act_register(cgi_sink *output,
   expand_template(ds, output, "login");
 }
 
+static void act_confirm(cgi_sink *output,
+                       dcgi_state *ds) {
+  const char *confirmation;
+
+  if(!(confirmation = cgi_get("confirm"))) {
+    cgi_set_option("error", "noconfirm");
+    expand_template(ds, output, "login");
+  }
+  if(disorder_confirm(ds->g->client, confirmation)) {
+    cgi_set_option("error", "badconfirm");
+    expand_template(ds, output, "login");
+  }
+  cgi_set_option("confirmed", "confirmedok");
+  expand_template(ds, output, "login");
+}
+
 static const struct action {
   const char *name;
   void (*handler)(cgi_sink *output, dcgi_state *ds);
 } actions[] = {
+  { "confirm", act_confirm },
   { "disable", act_disable },
   { "enable", act_enable },
   { "login", act_login },
@@ -1687,7 +1704,14 @@ static void perform_action(cgi_sink *output, dcgi_state *ds,
 void disorder_cgi(cgi_sink *output, dcgi_state *ds) {
   const char *action = cgi_get("action");
 
-  if(!action) action = "playing";
+  if(!action) {
+    /* We allow URLs which are just confirm=... in order to keep confirmation
+     * URLs, which are user-facing, as short as possible. */
+    if(cgi_get("confirm"))
+      action = "confirm";
+    else
+      action = "playing";
+  }
   perform_action(output, ds, action);
 }
 
index 6c1d0b9a5402a5ce4cdac60d28aa64fc3aa05ced..8f366bbbbf6232eaf83439c0c35f5ba50c3ca925 100644 (file)
@@ -38,6 +38,8 @@ USA
    <p>@label:login.registered@</p>
    }@
 
+  <!-- TODO report success of confirmation -->
+
    @if{@eq{@user@}{guest}@}{
    @#{guest user, allow login and registration}@
    <h2>Existing users</h2>