Browse Source

changed frontend to make it to use ldap login and simple session setup without username

master
Georg Hopp 14 years ago
parent
commit
785b1c361c
  1. 1
      assets/html/main.html
  2. 4
      assets/js/init.js
  3. 2
      assets/js/session.js
  4. 31
      src/http/worker/process.c

1
assets/html/main.html

@ -13,6 +13,7 @@
<body>
<ul id="menu">
<li>random Value</li>
<li>start session</li>
<li>login</li>
</ul>
<div id="sessinfo" class="x-small">

4
assets/js/init.js

@ -14,6 +14,10 @@ $(document).ready(function() {
});
$("ul#menu li:eq(1)").click(function() {
$.getJSON("/sess/", $.proxy(sess.loadJSON, sess));
});
$("ul#menu li:eq(2)").click(function() {
$("#login").removeClass("hide");
});

2
assets/js/session.js

@ -15,6 +15,8 @@ function Session(sId)
Session.prototype.loadJSON = function(data)
{
this.stop();
this.id = ("0" == data.id)? "none" : data.id;
this.timeout = data.timeout * 10;
this.timeleft = data.timeleft * 10;

31
src/http/worker/process.c

@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <sys/time.h>
#include "class.h"
@ -116,7 +117,7 @@ httpWorkerProcess(HttpWorker this, Stream st)
* an empty 200 OK
*/
if (NULL == password || NULL == username) {
response = new(HttpResponse, "HTTP/1.1", 200, "OK");
response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden");
}
if (NULL == response) {
@ -126,11 +127,22 @@ httpWorkerProcess(HttpWorker this, Stream st)
(char*)(password->value), password->nvalue);
if (!authenticate(this->auth, cred)) {
response = new(HttpResponse, "HTTP/1.1", 200, "OK");
response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden");
} else {
this->session = sessionAdd(
this->sroot,
new(Session, username->value, username->nvalue));
if (NULL == this->session) {
this->session = sessionAdd(
this->sroot,
new(Session,
username->value,
username->nvalue));
} else {
this->session->username = malloc(username->nvalue + 1);
this->session->username[username->nvalue] = 0;
memcpy(this->session->username,
username->value,
username->nvalue);
}
nbuf = sprintf(buffer,
"sid=%lu;Path=/",
this->session->id);
@ -161,6 +173,15 @@ httpWorkerProcess(HttpWorker this, Stream st)
response = (HttpMessage)httpResponseSession(this->session);
}
if (0 == strcmp("/sess/", request->path)) {
if (NULL == this->session) {
this->session = sessionAdd(
this->sroot,
new(Session, NULL, 0));
}
response = (HttpMessage)httpResponseSession(this->session);
}
if (0 == strcmp("/randval/", request->path)) {
if (NULL != this->session) {
response = (HttpMessage)httpResponseRandval(

Loading…
Cancel
Save