Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
laravel-blog
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e0507562
authored
Sep 07, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
middleware
1 parent
40f36deb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
2 deletions
app/Http/Kernel.php
app/Http/Middleware/AuthenticatedMiddleware.php
database/factories/ModelFactory.php
routes/web.php
app/Http/Kernel.php
View file @
e050756
...
@@ -56,5 +56,6 @@ class Kernel extends HttpKernel
...
@@ -56,5 +56,6 @@ class Kernel extends HttpKernel
'can'
=>
\Illuminate\Auth\Middleware\Authorize
::
class
,
'can'
=>
\Illuminate\Auth\Middleware\Authorize
::
class
,
'guest'
=>
\App\Http\Middleware\RedirectIfAuthenticated
::
class
,
'guest'
=>
\App\Http\Middleware\RedirectIfAuthenticated
::
class
,
'throttle'
=>
\Illuminate\Routing\Middleware\ThrottleRequests
::
class
,
'throttle'
=>
\Illuminate\Routing\Middleware\ThrottleRequests
::
class
,
'authenticated'
=>
\App\Http\Middleware\AuthenticatedMiddleware
::
class
];
];
}
}
app/Http/Middleware/AuthenticatedMiddleware.php
0 → 100644
View file @
e050756
<?php
namespace
App\Http\Middleware
;
use
Closure
;
use
Auth
;
class
AuthenticatedMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public
function
handle
(
$request
,
Closure
$next
)
{
if
(
Auth
::
check
())
return
$next
(
$request
);
return
redirect
(
'/login'
);
}
}
database/factories/ModelFactory.php
View file @
e050756
...
@@ -18,7 +18,7 @@ $factory->define(App\User::class, function (Faker\Generator $faker) {
...
@@ -18,7 +18,7 @@ $factory->define(App\User::class, function (Faker\Generator $faker) {
return
[
return
[
'name'
=>
$faker
->
name
,
'name'
=>
$faker
->
name
,
'email'
=>
$faker
->
unique
()
->
safeEmail
,
'email'
=>
$faker
->
unique
()
->
safeEmail
,
'password'
=>
$password
?:
$password
=
bcrypt
(
'secret'
)
,
'password'
=>
$password
?:
$password
=
'secret'
,
'remember_token'
=>
str_random
(
10
),
'remember_token'
=>
str_random
(
10
),
];
];
});
});
routes/web.php
View file @
e050756
...
@@ -32,7 +32,7 @@ Route::get('blade', 'PagesController@blade');
...
@@ -32,7 +32,7 @@ Route::get('blade', 'PagesController@blade');
// return $users;
// return $users;
// });
// });
Route
::
get
(
'users'
,
'UsersController@index'
);
Route
::
get
(
'users'
,
'UsersController@index'
)
->
middleware
(
'authenticated'
)
;
Route
::
get
(
'users/create'
,
'UsersController@create'
);
Route
::
get
(
'users/create'
,
'UsersController@create'
);
Route
::
post
(
'users'
,
'UsersController@store'
);
Route
::
post
(
'users'
,
'UsersController@store'
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment