mirror of
https://github.com/Relintai/mourne_rcpp_fw.git
synced 2024-12-27 23:17:11 +01:00
Updated the engine, and added a redirect to the login page from index if the user is not logged in.
This commit is contained in:
parent
fd37c75c47
commit
9aa2e64199
2
HEADS
2
HEADS
@ -1 +1 @@
|
|||||||
{"engine": {"master": "594ab744c52b4697464a49bf09f9895d97eb8723"}}
|
{"engine": {"master": "8e4bb75bcb12fcab39b4fd874fb279b7620bfaab"}}
|
@ -17,7 +17,20 @@
|
|||||||
#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) {
|
||||||
|
Ref<User> u = request->reference_data["user"];
|
||||||
|
|
||||||
|
if (!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) {
|
||||||
|
ENSURE_LOGIN(request);
|
||||||
|
|
||||||
add_menu(request, MENUENTRY_NEWS);
|
add_menu(request, MENUENTRY_NEWS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -45,12 +58,6 @@ void MourneApplication::index(Object *instance, Request *request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MourneApplication::session_middleware_func(Object *instance, Request *request) {
|
void MourneApplication::session_middleware_func(Object *instance, Request *request) {
|
||||||
std::cout << "test: session_middleware_func called" << std::endl;
|
|
||||||
|
|
||||||
//if fail
|
|
||||||
//request->send(); in middleware
|
|
||||||
|
|
||||||
request->next_stage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MourneApplication::add_menu(Request *request, const MenuEntries index) {
|
void MourneApplication::add_menu(Request *request, const MenuEntries index) {
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#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) \
|
||||||
|
if (!ensure_login(request)) { \
|
||||||
|
return;\
|
||||||
|
}
|
||||||
|
|
||||||
class MourneApplication : public DWebApplication {
|
class MourneApplication : public DWebApplication {
|
||||||
public:
|
public:
|
||||||
enum MenuEntries {
|
enum MenuEntries {
|
||||||
@ -29,6 +34,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static bool ensure_login(Request *request);
|
||||||
|
|
||||||
static void index(Object *instance, Request *request);
|
static void index(Object *instance, Request *request);
|
||||||
|
|
||||||
static void session_middleware_func(Object *instance, Request *request);
|
static void session_middleware_func(Object *instance, Request *request);
|
||||||
|
Loading…
Reference in New Issue
Block a user