chiark / gitweb /
The redirection after login now works properly.
authorrjk@greenend.org.uk <>
Sun, 23 Dec 2007 12:49:30 +0000 (12:49 +0000)
committerrjk@greenend.org.uk <>
Sun, 23 Dec 2007 12:49:30 +0000 (12:49 +0000)
The logout button sort of works; oddly you have to press it twice.

lib/client.c
lib/client.h
server/dcgi.c

index b7292c51f55d5c2062f87f8ee87c96f4da9b49b7..dc1d44ea4215c832d1f1a9e7e4264e89c86612dd 100644 (file)
@@ -1148,6 +1148,14 @@ int disorder_make_cookie(disorder_client *c, char **cookiep) {
                 cookiep);
 }
 
+/** @brief Revoke the cookie used by this session
+ * @param c Client
+ * @return 0 on success, non-0 on error
+ */
+int disorder_revoke(disorder_client *c) {
+  return disorder_simple(c, 0, "revoke", (char *)0);
+}
+
 /*
 Local Variables:
 c-basic-offset:2
index 7d6a47eab16fb38e859241715ed712ef774a2ba2..08de864f952a829859f4293a64cb542a2e3a48e6 100644 (file)
@@ -114,6 +114,7 @@ int disorder_register(disorder_client *c, const char *user,
 int disorder_confirm(disorder_client *c, const char *confirm);
 int disorder_make_cookie(disorder_client *c, char **cookiep);
 const char *disorder_last(disorder_client *c);
+int disorder_revoke(disorder_client *c);
 
 #endif /* CLIENT_H */
 
index b9e4b60fc62db4a3a6ce91016b973fc7e5d8065c..f14d8bf4aaf0c74027d669af66392a5e2595298d 100644 (file)
@@ -104,8 +104,8 @@ static const char *front_url(void) {
 static void redirect(struct sink *output) {
   const char *back;
 
-  cgi_header(output, "Location",
-            (back = cgi_get("back")) ? back : front_url());
+  back = cgi_get("back");
+  cgi_header(output, "Location", back && *back ? back : front_url());
   cgi_body(output);
 }
 
@@ -460,6 +460,14 @@ static void act_login(cgi_sink *output,
     expand_template(ds, output, "login");
 }
 
+static void act_logout(cgi_sink *output,
+                      dcgi_state *ds) {
+  disorder_revoke(ds->g->client);
+  login_cookie = 0;
+  /* Back to the login page */
+  expand_template(ds, output, "login");
+}
+
 static void act_register(cgi_sink *output,
                         dcgi_state *ds) {
   const char *username, *password, *email;
@@ -508,6 +516,7 @@ static const struct action {
   { "disable", act_disable },
   { "enable", act_enable },
   { "login", act_login },
+  { "logout", act_logout },
   { "move", act_move },
   { "pause", act_pause },
   { "play", act_play },