그냥 사는 이야기

Laravel 5.3 Sentinel - Login 본문

Development/Web

Laravel 5.3 Sentinel - Login

없다캐라 2020. 1. 21. 10:41
반응형

LoginController 생성

php artisan make:controller LoginController
LoginController
public function login()
{
    return view('authentication.login');
}

Route 추가

web.php
Route::get('/login', 'LoginController@login');

View 생성

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title"> Login </h3>
                </div>

                <div class="panel-body">
                    <form action="/login" method="POST">
                        {{ csrf_field() }}

                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-envelope"></i></span>
                                <input type="email" name="email" class="form-control" placeholder="example@example.com" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                <input type="password" name="password" class="form-control" placeholder="Password" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <input type="submit" value="Login" class="btn btn-success pull-right">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

post login 작성

web.php
Route::get('/login', 'LoginController@login');
LoginController
public function postLogin(Request $request)
{
    Sentinel::authenticate($request->all());

    return Sentinel::check();
}
Comments