Redirection et page privé de l'utilisateur
This commit is contained in:
@@ -34,6 +34,7 @@ int v_password_func(struct http_request *, char *);
|
||||
int create_user(struct http_request *);
|
||||
int v_session_validate(struct http_request *, char *);
|
||||
int v_session_remove(struct http_request *, char *);
|
||||
int private_portal(struct http_request *);
|
||||
|
||||
hashtable_t *hashtable = NULL;
|
||||
|
||||
@@ -142,9 +143,10 @@ int create_user(struct http_request *req)
|
||||
}
|
||||
|
||||
sqlite3_close(db);
|
||||
http_response_header(req, "location", "/");
|
||||
http_response_header(req, "content-type", "text/html");
|
||||
d = kore_buf_release(b, &len);
|
||||
http_response(req, 200, d, len);
|
||||
http_response(req, HTTP_STATUS_FOUND, NULL, 0);
|
||||
kore_free(d);
|
||||
|
||||
return (KORE_RESULT_OK);
|
||||
@@ -266,8 +268,10 @@ int portal_user_load(struct http_request *req)
|
||||
if (cookie != NULL)
|
||||
http_response_header(req, "set-cookie", cookie);
|
||||
d = kore_buf_release(b, &len);
|
||||
http_response(req, 200, d, len);
|
||||
kore_free(d);
|
||||
|
||||
http_response_header(req, "location", "/portal/bienvenue");
|
||||
http_response(req, HTTP_STATUS_FOUND, NULL, 0);
|
||||
kore_free(d);
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
@@ -294,10 +298,10 @@ int v_session_remove (struct http_request *req, char *data)
|
||||
|
||||
if (ht_get(hashtable, buffer) != NULL)
|
||||
ht_delete(hashtable, buffer);
|
||||
|
||||
http_response_header(req, "location", "/");
|
||||
http_response_header(req, "content-type", "text/html");
|
||||
http_response_header(req, "set-cookie", "session_id=");
|
||||
http_response(req, 200, asset_index_html, asset_len_index_html);
|
||||
http_response_header(req, "set-cookie", "session_id=""");
|
||||
http_response(req, HTTP_STATUS_FOUND, NULL, 0);
|
||||
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
@@ -311,3 +315,27 @@ int v_session_validate(struct http_request *req, char *data)
|
||||
|
||||
return (KORE_RESULT_ERROR);
|
||||
}
|
||||
|
||||
int private_portal(struct http_request *req)
|
||||
{
|
||||
struct kore_buf *b = NULL;
|
||||
u_int8_t *d = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (req->method == HTTP_METHOD_GET)
|
||||
http_populate_get(req);
|
||||
|
||||
b = kore_buf_alloc(asset_len_signup_html);
|
||||
kore_buf_append(b, asset_private_html, asset_len_private_html);
|
||||
|
||||
|
||||
if (req->method == HTTP_METHOD_GET) {
|
||||
kore_buf_replace_string(b, "$msg$", "GO", 4);
|
||||
|
||||
http_response_header(req, "content-type", "text/html");
|
||||
d = kore_buf_release(b, &len);
|
||||
http_response(req, 200, d, len);
|
||||
kore_free(d);
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user