2015-10-11 7 views
0

Im пытаюсь создать форму и autheticate пользователя с помощью встроенного в аутентификации в Laravel, я последовал за этот учебник https://www.youtube.com/watch?v=bqkt6eSsRZs&feature=iv&src_vid=xn2snypAcIQ&annotation_id=annotation_2749752877 но мне кажется, мой не перенаправляя в «/ дом»postRegister не работает Laravel 5,1

Вот моя форма :

в login.blade.php (копируется из документации)

<!-- resources/views/auth/login.blade.php --> 

<form method="POST" action="/auth/login"> 
    {!! csrf_field() !!} 

    <div> 
     Email 
     <input type="email" name="email" value="{{ old('email') }}"> 
    </div> 

    <div> 
     Password 
     <input type="password" name="password" id="password"> 
    </div> 

    <div> 
     <input type="checkbox" name="remember"> Remember Me 
    </div> 

    <div> 
     <button type="submit">Login</button> 
    </div> 
</form> 

register.blade.php

<!-- resources/views/auth/register.blade.php --> 

<form method="POST" action="/auth/register"> 
    {!! csrf_field() !!} 

    <div> 
     Name 
     <input type="text" name="name" value="{{ old('name') }}"> 
    </div> 

    <div> 
     Email 
     <input type="email" name="email" value="{{ old('email') }}"> 
    </div> 

    <div> 
     Password 
     <input type="password" name="password"> 
    </div> 

    <div> 
     Confirm Password 
     <input type="password" name="password_confirmation"> 
    </div> 

    <div> 
     <button type="submit">Register</button> 
    </div> 
</form> 

маршрутный список

+--------+----------+---------------+------+-------------------------------------------------------+------------+ 
| Domain | Method | URI   | Name | Action            | Middleware | 
+--------+----------+---------------+------+-------------------------------------------------------+------------+ 
|  | GET|HEAD |/   |  | Closure            |   | 
|  | GET|HEAD | auth/login |  | App\Http\Controllers\Auth\[email protected]  | guest  | 
|  | POST  | auth/login |  | App\Http\Controllers\Auth\[email protected] | guest  | 
|  | GET|HEAD | auth/logout |  | App\Http\Controllers\Auth\[email protected] |   | 
|  | POST  | auth/register |  | App\Http\Controllers\Auth\[email protected] | guest  | 
|  | GET|HEAD | auth/register |  | App\Http\Controllers\Auth\[email protected] | guest  | 
|  | GET|HEAD | home   |  | Closure            |   | 
+--------+----------+---------------+------+-------------------------------------------------------+------------+ 

route.php

<?php 

/* 
|-------------------------------------------------------------------------- 
| Application Routes 
|-------------------------------------------------------------------------- 
| 
| Here is where you can register all of the routes for an application. 
| It's a breeze. Simply tell Laravel the URIs it should respond to 
| and give it the controller to call when that URI is requested. 
| 
*/ 

Route::get('/', function() { 
    return view('welcome'); 
}); 

Route::get('home', function(){ 
    echo "welcome home"; 
}); 

// Authentication routes... 
Route::get('auth/login', 'Auth\[email protected]'); 
Route::post('auth/login', 'Auth\[email protected]'); 
Route::get('auth/logout', 'Auth\[email protected]'); 

// Registration routes... 
Route::get('auth/register', 'Auth\[email protected]'); 
Route::post('auth/register', 'Auth\[email protected]'); 

ответ

0

Вы можете установить путь переадресации в AuthController так:

protected $redirectPath = '/home';

Таким образом, в вашем контроллере это будет выглядеть :

//The beginning of the controller.... 

class AuthController extends Controller 
{ 
    /* 
    |-------------------------------------------------------------------------- 
    | Registration & Login Controller 
    |-------------------------------------------------------------------------- 
    | 
    | This controller handles the registration of new users, as well as the 
    | authentication of existing users. By default, this controller uses 
    | a simple trait to add these behaviors. Why don't you explore it? 
    | 
    */ 

    use AuthenticatesAndRegistersUsers, ThrottlesLogins; 
    private $redirectTo = '/home'; 

    //The rest of the controller... 

Проверьте это в docs.