forked from baniol/gotin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.php
executable file
·83 lines (65 loc) · 2.69 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
<?php
/**
* Routing for Gotin bundle
*
* @license http://www.opensource.org/licenses/mit MIT License
* @copyright Marcin Baniowski (http://baniowski.pl)
* @subpackage Routes
* @author Marcin Baniowski
* @package Gotin\Routes
*/
// register all controllers for the "gotin" bundle
Route::controller( Controller::detect( 'gotin' ) );
if ((Config::get('gotin::gotin.login_mode') == "classic")) {
// redirects root url ("/") to login view
Route::any( '/login', 'gotin::login@login' );
Route::any( '/register', 'gotin::login@register' );
Route::any( '/forgot-password', 'gotin::login@forgot' );
}else{
Route::get( '(:bundle)', 'gotin::login@login' );
}
// logout route
Route::get( '(:bundle)/logout', 'gotin::login@logout' );
// edit profile
Route::any( '(:bundle)/editprofile', 'gotin::users@editprofile' );
// delete profile
Route::any( '(:bundle)/deleteaccount', 'gotin::users@deleteaccount' );
// sets ajax routes for main actions (login,register,forgot password)
if ( Request::ajax() ) {
Route::post( 'gotin/loginajax', 'gotin::login@loginajax' );
Route::post( 'gotin/registerajax', 'gotin::login@registerajax' );
Route::post( 'gotin/forgotajax', 'gotin::login@forgotajax' );
}
Route::any( '(:bundle)/users/(:any?)', array( 'defaults' => 'index', 'uses' => '(:bundle):users@(:1)' ) );
Route::any( '(:bundle)/roles/(:any?)', array( 'defaults' => 'index', 'uses' => '(:bundle):roles@(:1)' ) );
// @todo gropuping: http://laravel.com/docs/routing#route-groups
Route::filter( 'before', function() {
// add styles to layout
Asset::container('header')->add('bootstrap_style','bundles/gotin/css/bootstrap.css');
Asset::container('header')->add('bootstrap_res','bundles/gotin/css/bootstrap-responsive.css');
Asset::container('header')->add('docs_style','bundles/gotin/css/gotin.css');
Asset::container('header')->add('gotin_style','bundles/gotin/css/docs.css');
// add scripts to layout
Asset::container('header')->add('jquery','bundles/gotin/js/jquery.js');
Asset::container('header')->add('bootstrap','bundles/gotin/js/bootstrap.min.js');
if ((Config::get('gotin::gotin.login_mode') == "ajax"))
Asset::container('header')->add('gotin','bundles/gotin/js/gotin.js');
});
/**
* Filter admin access
*/
Route::filter( 'auth', function() {
if(!Auth::gotin_check()) {
Auth::logout();
return Redirect::to_action( 'login' );
}
// Admin role protected routes
$admin_protected = array( 'users', 'roles' );
$gotin_route = Bundle::get( 'gotin' )['handles'];
foreach ( $admin_protected as $ap ) {
$r = $gotin_route . "\/" . $ap;
$match = preg_match( "/".$r."/", URI::current() );
if ( $match && !Auth::is( "Admin" ) )
return Redirect::to_action( 'gotin::dashboard' );
}
} );