From 42f7ad74009e240c89775d8b977b3750fd5d3c30 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 22 Sep 2013 18:57:10 +0100 Subject: [PATCH] login via ldap and gdbm now works. Signup stores the user account as well as the credentials but still returns a 500 and I have a memory leak most likely within the queue code. To reproduce this one has to start the server and send two requests via telnet to the server...no keep-alive just a single GET. refs #36 --- assets/js/session.js | 9 ++++++++- src/application/adapter/http/update.c | 1 + src/application/application.c | 4 ---- src/application/login.c | 6 +----- src/auth/ldap.c | 3 ++- src/http/response.c | 2 +- src/queue/get.c | 4 ++-- src/session/session.c | 5 ++++- src/storage/storage.c | 5 ++++- 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/assets/js/session.js b/assets/js/session.js index 9e3e8be..248b047 100644 --- a/assets/js/session.js +++ b/assets/js/session.js @@ -28,8 +28,15 @@ Session.prototype.loadJSON = function(data) this.firstname = data.firstname; this.surname = data.surname; + name = " "; + this.eSid.empty().append(this.id); - $("#main p:eq(1) span:eq(0)").empty().append(" " + this.firstname + " " + this.surname); + if ('(null)' == this.firstname || '(null)' == this.surname) { + name += this.email; + } else { + name += this.firstname + " " + this.surname; + } + $("#main p:eq(1) span:eq(0)").empty().append(name); this.draw(); if (0 < this.timeleft) diff --git a/src/application/adapter/http/update.c b/src/application/adapter/http/update.c index b0c872f..2b6f967 100644 --- a/src/application/adapter/http/update.c +++ b/src/application/adapter/http/update.c @@ -223,6 +223,7 @@ signupAdapter(Application application, HttpWorker worker, Session session) } delete(credential); + delete(user); } diff --git a/src/application/application.c b/src/application/application.c index e7c469e..755210f 100644 --- a/src/application/application.c +++ b/src/application/application.c @@ -71,10 +71,6 @@ applicationDtor(void * _this) delete(this->active_sessions); - for (i=0; inauth; i++) { - delete(this->auth[i]); - } - MEM_FREE(this->auth); } diff --git a/src/application/login.c b/src/application/login.c index 627c2b7..9cc2c28 100644 --- a/src/application/login.c +++ b/src/application/login.c @@ -50,11 +50,7 @@ applicationLogin( session->user->email = CRED_PWD(credential).user; session->user->nemail = &CRED_PWD(credential).nuser; - if (NULL == userLoad(session->user, this->users)) { - session->user->email = NULL; - session->user->nemail = NULL; - } - + userLoad(session->user, this->users); break; default: diff --git a/src/auth/ldap.c b/src/auth/ldap.c index c5975d6..c1e98c4 100644 --- a/src/auth/ldap.c +++ b/src/auth/ldap.c @@ -111,7 +111,8 @@ authLdapAuthenticate(void * _this, Credential cred) return TRUE; } - fprintf(stderr, "%s\n", ldap_err2string(ldap_err)); + //fprintf(stderr, "%s\n", ldap_err2string(ldap_err)); + // @TODO do error logging instead. return FALSE; } diff --git a/src/http/response.c b/src/http/response.c index 9a14315..b950c11 100644 --- a/src/http/response.c +++ b/src/http/response.c @@ -45,7 +45,7 @@ httpResponseCtor(void * _this, va_list * params) this->status = va_arg(* params, unsigned int); reason = va_arg(* params, char *); - this->reason = memCalloc(1, strlen(reason)+1); + this->reason = memCalloc(1, strlen(reason)+1); strcpy(this->reason, reason); return 0; diff --git a/src/queue/get.c b/src/queue/get.c index 20ca7f0..fdbf41e 100644 --- a/src/queue/get.c +++ b/src/queue/get.c @@ -26,8 +26,8 @@ void * queueGet(Queue this) { - Queue first; - void * msg; + Queue first; + void * msg; if (NULL == this->first) { return NULL; diff --git a/src/session/session.c b/src/session/session.c index ff46cc2..aeca7d1 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -40,7 +40,7 @@ static int sessionCtor(void * _this, va_list * params) { - Session this = _this; + Session this = _this; uuid_t uuid; this->livetime = time(NULL) + SESSION_LIVETIME; @@ -56,6 +56,9 @@ static void sessionDtor(void * _this) { + Session this = _this; + + delete(this->user); } static diff --git a/src/storage/storage.c b/src/storage/storage.c index efb372e..9e8df6a 100644 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -60,7 +60,10 @@ storageDtor(void * _this) Storage this = _this; if (NULL != this->db_name) MEM_FREE(this->db_name); - if (NULL != this->gdbm) gdbm_close(this->gdbm); + if (NULL != this->gdbm) { + gdbm_close(this->gdbm); + this->gdbm = NULL; + } } INIT_IFACE(Class, storageCtor, storageDtor, NULL);