diff options
Diffstat (limited to 'public/app/routes/frontend.php')
| -rw-r--r-- | public/app/routes/frontend.php | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/public/app/routes/frontend.php b/public/app/routes/frontend.php index 48d5da3..d58d483 100644 --- a/public/app/routes/frontend.php +++ b/public/app/routes/frontend.php @@ -1,51 +1,61 @@ <?php use app\controllers\Auth; -use app\controllers\App_user; -use app\controllers\Office; -use app\extends\Cache_service; // Home/Welcome //////////////////////////////////////////////////////////////////////////////// -// Route::add('/', function() { Render::view('welcome'); }); -Route::add('/', function() { Render::view('user/login'); }); +// welcome -> redirecto to login +Route::add('/', function() { header("Location: /login");; }); -// invitation +// Error pages //////////////////////////////////////////////////////////////////////////////// -// request invitation (for account activation) -// --- -- -- - - - -Route::add('/invitation/([0-9a-f]*)', function($id) { - if ($id == "" || $id == "0") { Render::view('error/404'); - } else { - Auth::invitation($id); - } +Route::notFound( function() { // 404 error page + header("HTTP/1.0 404 Not Found"); + Render::view('error/404', ['message' => 'nobody knows it (but you got a secret smile;)']); }); -// request activation (submit invitation; POST:form is sent) -// --- -- -- - - - -Route::add('/account/activate', function() { Auth::activate(); }, 'post'); -// DEPRICATED: user sends a registration form -// --- -- -- - - - -# Route::add('/account/register', function() { -# $response = Auth::register(); -# Render::json($response); -# },'post'); +// NOTE: this set of routes defines all valid NON-AUTHenticated requests +//////////////////////////////////////////////////////////////////////////////// +if (!Auth::is_connected()) { -// Error pages -//////////////////////////////////////////////////////////////////////////////// + // request login + // render Form -> will POST: /account/check-login + // --- -- -- - - - + Route::add('/login', function() { Render::view('user/login'); }); -Route::notFound( function() { // 404 error page - header("HTTP/1.0 404 Not Found"); - Render::view('error/404', ['message' => 'nobody knows it (but you got a secret smile;)']); -}); + + // user sends login form + // --- -- -- - - - + Route::add('/account/check-login', function() { + $response = Auth::login(); + Render::json(['status' => $response]); + }, 'post'); + + + // request invitation (for account activation) + // render Form -> will POST /account/activate + // --- -- -- - - - + Route::add('/invitation/([0-9a-f]*)', function($id) { + if ($id == "" || $id == "0") { Render::view('error/404'); + } else { + Auth::invitation($id); + } + }); + + + // POST invitation = activate + // --- -- -- - - - + Route::add('/account/activate', function() { Auth::activate(); }, 'post'); + +} |
