From: rjk@greenend.org.uk <> Date: Sun, 23 Dec 2007 12:49:30 +0000 (+0000) Subject: The redirection after login now works properly. X-Git-Tag: 3.0~165 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/b42ffad6922d87580e3edf528870f079f21dfd07 The redirection after login now works properly. The logout button sort of works; oddly you have to press it twice. --- diff --git a/lib/client.c b/lib/client.c index b7292c5..dc1d44e 100644 --- a/lib/client.c +++ b/lib/client.c @@ -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 diff --git a/lib/client.h b/lib/client.h index 7d6a47e..08de864 100644 --- a/lib/client.h +++ b/lib/client.h @@ -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 */ diff --git a/server/dcgi.c b/server/dcgi.c index b9e4b60..f14d8bf 100644 --- a/server/dcgi.c +++ b/server/dcgi.c @@ -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 },