From 52f6fbc52a6977f6dda57f596c2b8076a9760cbb Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 00:32:06 +0100 Subject: [PATCH] logout no longer tries to stop the session. Now simply the user is removed. --- include/application/application.h | 5 ++-- src/application/Makefile.am | 1 + src/application/adapter/http/update.c | 11 +------- src/application/logout.c | 38 +++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 src/application/logout.c diff --git a/include/application/application.h b/include/application/application.h index f796295..59d8fa9 100644 --- a/include/application/application.h +++ b/include/application/application.h @@ -54,8 +54,9 @@ CLASS(Application) { const char * version; }; -int applicationLogin(Application, Credential, Session); -int applicationSignup(Application, Credential, User, Session); +int applicationLogin(Application, Credential, Session); +void applicationLogout(Application, Session); +int applicationSignup(Application, Credential, User, Session); Session applicationSessionStart(Application); Session applicationSessionGet(Application, const char *); diff --git a/src/application/Makefile.am b/src/application/Makefile.am index 6470348..d58a230 100644 --- a/src/application/Makefile.am +++ b/src/application/Makefile.am @@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = subdir-objects APPLICATION = application.c \ login.c \ + logout.c \ signup.c \ session_start.c \ session_stop.c \ diff --git a/src/application/adapter/http/update.c b/src/application/adapter/http/update.c index 5cf9e75..5f24312 100644 --- a/src/application/adapter/http/update.c +++ b/src/application/adapter/http/update.c @@ -178,7 +178,6 @@ applicationAdapterHttpUpdate(void * _this, void * subject) Session session; char buf[200]; size_t nbuf; - time_t now = time(NULL); sid = getSessionId(worker->current_request->cookies); @@ -219,15 +218,7 @@ applicationAdapterHttpUpdate(void * _this, void * subject) } if (0 == strcmp("/logout/", worker->current_request->path)) { - applicationSessionStop( - this->application, - session); - - // remove session cookie - nbuf = sprintf(buf, "sid=%s;Path=/;Max-Age=-3600", session->id); - queuePut( - worker->additional_headers, - new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf)); + applicationLogout(this->application, session); worker->current_response = (HttpMessage)httpResponseUser(session->user); diff --git a/src/application/logout.c b/src/application/logout.c new file mode 100644 index 0000000..5f9993a --- /dev/null +++ b/src/application/logout.c @@ -0,0 +1,38 @@ +/** + * \file + * + * \author Georg Hopp + * + * \copyright + * Copyright © 2012 Georg Hopp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#define _GNU_SOURCE + +#include "class.h" +#include "auth.h" + +#include "utils/memory.h" +#include "application/application.h" + + +void +applicationLogout(Application this, Session session) +{ + delete(session->user); +} + +// vim: set ts=4 sw=4: