File tree 3 files changed +42
-3
lines changed
3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Lio \Http \Filters ;
3
+
4
+ use Illuminate \Auth \AuthManager ;
5
+
6
+ class Banned
7
+ {
8
+ /**
9
+ * @var \Illuminate\Auth\Guard
10
+ */
11
+ private $ auth ;
12
+
13
+ /**
14
+ * @param \Illuminate\Auth\AuthManager $auth
15
+ */
16
+ public function __construct (AuthManager $ auth )
17
+ {
18
+ $ this ->auth = $ auth ;
19
+ }
20
+
21
+ /**
22
+ * Logout the user if he's banned
23
+ *
24
+ * If the current authenticated user is banned and is trying
25
+ * to access protected areas, log him out of the system.
26
+ *
27
+ * @return void
28
+ */
29
+ public function filter ()
30
+ {
31
+ if ($ this ->auth ->check () && $ this ->auth ->user ()->is_banned ) {
32
+ $ this ->auth ->logout ();
33
+ }
34
+ }
35
+ }
36
+
Original file line number Diff line number Diff line change @@ -35,11 +35,12 @@ public function postEdit($userId)
35
35
$ user = $ this ->users ->requireById ($ userId );
36
36
37
37
$ user ->fill (Input::all ());
38
- if ( ! Input::has ('is_banned ' )) {
38
+
39
+ if (! Input::has ('is_banned ' )) {
39
40
$ user ->is_banned = 0 ;
40
41
}
41
42
42
- if ( ! $ user ->isValid ()) {
43
+ if (! $ user ->isValid ()) {
43
44
return $ this ->redirectBack (['errors ' => $ user ->getErrors ()]);
44
45
}
45
46
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ Route::filter ('banned ' , 'Lio\Http\Filters\Banned ' );
4
+
3
5
Route::group (array ('domain ' => 'bin.laravel.io ' ), function () {
4
6
Route::get ('{wildcard} ' , function ($ wildcard ) {
5
7
return Redirect::to ('http://laravel.io/bin/ ' . $ wildcard );
69
71
// Route::get('articles/search', 'ArticlesController@getSearch');
70
72
71
73
// forum
72
- Route::group (['before ' => 'auth ' ], function () {
74
+ Route::group (['before ' => 'auth|banned ' ], function () {
73
75
Route::get ('forum/create-thread ' , 'ForumThreadsController@getCreateThread ' );
74
76
Route::post ('forum/create-thread ' , 'ForumThreadsController@postCreateThread ' );
75
77
You can’t perform that action at this time.
0 commit comments