Помогите не работает редирект в Laravel 5.7 на Homestead 7.1.0
прикрепляю исходники:
Файл register.blade.php
@include("/page/head")
<link href={{mix("css/semantic.css")}} rel="stylesheet">
@include("/page/start")
<h2 class="ui teal header">
<div class="content">
Регистрация на PEOPLES
</div>
</h2>
<form class="ui large form" id="registerForm" method="post">
{{csrf_field()}}
<div class="ui stacked segment">
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="text" name="email" placeholder="Ваш email">
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input type="password" name="password" placeholder="Ваш пароль">
</div>
</div>
<button class="ui fluid large teal submit button" onclick="checkRegister();">Зарегистрироваться</button>
</div>
<div class="ui error message"></div>
<br><label id="registerFail" style="color:red;"></label>
</form>
<div class="ui message">
Уже регистрировались? <a href="/login">Войти</a>
</div>
<script src="{{mix('js/app.js')}}"></script>
<script src="{{mix('js/jquery.js')}}"></script>
<script src="{{mix('js/semantic.js')}}"></script>
<script>
$(document).ready(function() {
$('.ui.form').form({
fields: {
email: {
identifier : 'email',
rules: [
{
type : 'empty',
prompt : 'Пожалуйста введите ваш e-mail'
},
{
type : 'email',
prompt : 'Пожалуйста введите правильный e-mail'
}
]
},
password: {
identifier : 'password',
rules: [
{
type : 'empty',
prompt : 'Пожалуйста введите пароль'
},
{
type : 'length[4]',
prompt : 'Ваш пароль должен быть длиной от 4 символов'
}
]
}
}
});
});
function checkRegister()
{
$("#registerFail").text('');
$("#registerForm").on('submit', function (e) {
e.preventDefault();
var form = this;
if( $('.ui.form').form('is valid'))
{
$.ajax({
url: '/register',
type: 'post',
data: {_token: $('meta[name="csrf-token"]').attr('content'), email: $("input[name=email]").val(), password: $("input[name=password]").val()},
dataType: 'JSON',
success: function (data) {
if (data.state != 'register_ok')
{
$("#registerFail").text(data.state);
}
}
});
}
});
}
</script>
@include("/page/end")
Файл /page/head.blade.php
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{csrf_token()}}">
<title>{{ config('app.name') }}</title>
Файл /page/start.blade.php
</head>
<body>
<div class="pusher">
<div class="ui vertical teal inverted center aligned segment">
<h3>PEOPLES - социальная сеть.</h3>
</div>
<div id="menu" class="ui secondary pointing menu">
</div>
<div id="application" class="ui middle aligned center aligned grid">
<div class="column" style="max-width:450px;margin-top:20px;">
<div id="app">
Файл /page/end.blade.php
</div>
</div>
</div>
</div>
</body>
</html>
Файл routes/web.php
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/register', 'AuthController@register');
Route::post('/register', 'AuthController@register');
Файл /app/Http/Controllers/AuthController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use App\User;
use Hash;
class AuthController extends Controller
{
public function register(Request $request)
{
$email = Input::get('email');
$password = Input::get('password');
$exist = User::where('email', $email)->first();
if ($email == null || $password == null)
{
return view('/register');
}
if ($request->isMethod('post'))
{
if ($exist == null)
{
$user = new User;
$user->email = $email;
$user->password_hash = Hash::make($password);
date_default_timezone_set('Europe/Moscow');
$user->created_at = date('Y-m-d H:i:s');
$user->reset_date = date('Y-m-d H:i:s', (time() - 15*60));
$user->money = 600;
$user->save();
Auth::attempt(['email' => $email, 'password' => $password], true);
if (Auth::check())
{
return redirect('/home');
} else
{
return response()->json([
'state' => 'Ошибка авторизации.',
]);
}
} else
{
return response()->json([
'state' => 'Такой email уже зарегистрирован!',
]);
}
}
}
}