mirror of
https://github.com/Relintai/mourne_rcpp_fw.git
synced 2025-01-13 07:41:12 +01:00
Small improvements.
This commit is contained in:
parent
9aa2e64199
commit
deb3a6dd08
@ -17,15 +17,10 @@
|
|||||||
#include "modules/users/user.h"
|
#include "modules/users/user.h"
|
||||||
#include "modules/users/user_controller.h"
|
#include "modules/users/user_controller.h"
|
||||||
|
|
||||||
bool MourneApplication::ensure_login(Request *request) {
|
bool MourneApplication::is_logged_in(Request *request) {
|
||||||
Ref<User> u = request->reference_data["user"];
|
Ref<User> u = request->reference_data["user"];
|
||||||
|
|
||||||
if (!u.is_valid()) {
|
return u.is_valid();
|
||||||
request->send_redirect("/user/login");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MourneApplication::index(Object *instance, Request *request) {
|
void MourneApplication::index(Object *instance, Request *request) {
|
||||||
@ -51,7 +46,6 @@ void MourneApplication::index(Object *instance, Request *request) {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//dynamic_cast<ListPage *>(instance)->index(request);
|
//dynamic_cast<ListPage *>(instance)->index(request);
|
||||||
request->body += "test";
|
request->body += "test";
|
||||||
request->compile_and_send_body();
|
request->compile_and_send_body();
|
||||||
@ -67,7 +61,7 @@ void MourneApplication::add_menu(Request *request, const MenuEntries index) {
|
|||||||
|
|
||||||
HTMLTag *t;
|
HTMLTag *t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<?php if ($weather): ?>
|
<?php if ($weather): ?>
|
||||||
<div class="menu_base <?=$weather['css']; ?>">
|
<div class="menu_base <?=$weather['css']; ?>">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
@ -193,7 +187,7 @@ void MourneApplication::add_menu(Request *request, const MenuEntries index) {
|
|||||||
b.div()->cls("nofloat");
|
b.div()->cls("nofloat");
|
||||||
b.cdiv();
|
b.cdiv();
|
||||||
}
|
}
|
||||||
|
|
||||||
b.cdiv();
|
b.cdiv();
|
||||||
b.div()->cls("main");
|
b.div()->cls("main");
|
||||||
b.write_tag();
|
b.write_tag();
|
||||||
@ -212,7 +206,9 @@ void MourneApplication::village_page_func(Object *instance, Request *request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MourneApplication::user_page_func(Object *instance, Request *request) {
|
void MourneApplication::user_page_func(Object *instance, Request *request) {
|
||||||
add_menu(request, MENUENTRY_SETTINGS);
|
if (is_logged_in(request)) {
|
||||||
|
add_menu(request, MENUENTRY_SETTINGS);
|
||||||
|
}
|
||||||
|
|
||||||
UserController::get_singleton()->handle_request_default(request);
|
UserController::get_singleton()->handle_request_default(request);
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
#include "modules/paged_article/paged_article.h"
|
#include "modules/paged_article/paged_article.h"
|
||||||
#include "modules/paged_list/paged_list.h"
|
#include "modules/paged_list/paged_list.h"
|
||||||
|
|
||||||
#define ENSURE_LOGIN(request) \
|
#define ENSURE_LOGIN(request) \
|
||||||
if (!ensure_login(request)) { \
|
if (!is_logged_in(request)) { \
|
||||||
return;\
|
request->send_redirect("/user/login"); \
|
||||||
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
class MourneApplication : public DWebApplication {
|
class MourneApplication : public DWebApplication {
|
||||||
@ -34,7 +35,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool ensure_login(Request *request);
|
static bool is_logged_in(Request *request);
|
||||||
|
|
||||||
static void index(Object *instance, Request *request);
|
static void index(Object *instance, Request *request);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user