This repository has been archived by the owner on Sep 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
routes.php
152 lines (130 loc) · 3.88 KB
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/*
|--------------------------------------------------------------------------
| Installer
|--------------------------------------------------------------------------
|
| Run installation route when Orchestra is not installed yet.
|
*/
Route::any('(:bundle)/installer/?(:any)?/?(:num)?', function ($action = 'index', $steps = 0)
{
// we should disable this routing when the system detect it's already
// running/installed.
if (Orchestra\Installer::installed()
and ( ! ($action === 'steps' && intval($steps) === 2)))
{
return Response::error('404');
}
// Otherwise, install it right away.
return Controller::call("orchestra::installer@{$action}", array($steps));
});
/*
|--------------------------------------------------------------------------
| Default Routing
|--------------------------------------------------------------------------
*/
Route::any('(:bundle)', array(
'before' => array('orchestra::installed', 'orchestra::auth'),
function ()
{
// Display the dashboard
return Controller::call('orchestra::dashboard@index');
},
));
/*
|--------------------------------------------------------------------------
| Credential Routing
|--------------------------------------------------------------------------
*/
Route::any('(:bundle)/(login|register|logout)', function ($action)
{
return Controller::call("orchestra::credential@{$action}");
});
/*
|--------------------------------------------------------------------------
| Controllers
|--------------------------------------------------------------------------
|
| Detects all controller under Orchestra bundle and register it to routing.
|
*/
Route::controller(array(
'orchestra::account',
'orchestra::bundles',
'orchestra::credential',
'orchestra::dashboard',
'orchestra::extensions',
'orchestra::forgot',
'orchestra::manages',
'orchestra::pages',
'orchestra::publisher',
'orchestra::resources',
'orchestra::settings',
'orchestra::users',
));
/*
|--------------------------------------------------------------------------
| Route Filtering
|--------------------------------------------------------------------------
*/
Route::filter('orchestra::auth', function ()
{
Session::flash('orchestra.redirect', Input::get('redirect'));
// Redirect the user to login page if user is not logged in.
if (Auth::guest()) return Redirect::to(handles('orchestra::login'));
});
Route::filter('orchestra::not-auth', function ()
{
Session::flash('orchestra.redirect', Input::get('redirect'));
// Redirect the user to dashboard page if user is logged in.
if ( ! Auth::guest()) return Redirect::to(handles('orchestra'));
});
Route::filter('orchestra::manage-users', function ()
{
// Redirect the user to login page if user is not logged in.
if ( ! Orchestra\Core::acl()->can('manage-users'))
{
if (Auth::guest())
{
Session::flash('orchestra.redirect', Input::get('redirect'));
return Redirect::to(handles('orchestra::login'));
}
return Redirect::to(handles('orchestra'));
}
});
Route::filter('orchestra::manage', function ()
{
// Redirect the user to login page if user is not logged in.
if ( ! Orchestra\Core::acl()->can('manage-orchestra'))
{
if (Auth::guest())
{
Session::flash('orchestra.redirect', Input::get('redirect'));
return Redirect::to(handles('orchestra::login'));
}
return Redirect::to(handles('orchestra'));
}
});
Route::filter('orchestra::allow-registration', function ()
{
$memory = Orchestra\Core::memory();
// Return 404 if registration is not enabled.
if ( ! $memory->get('site.users.registration', false))
{
return Response::error('404');
}
});
Route::filter('orchestra::installed', function ()
{
// we should run installer when the system detect it's already running
// or installed.
if ( ! Orchestra\Installer::installed())
{
return Redirect::to_action("orchestra::installer@index");
}
});
Route::filter('orchestra::csrf', function()
{
if (Request::forged()) return Response::error('500');
});