Я новичок в Ларавеле. Я пытаюсь написать пример входа в систему, но он показывает ошибку «302 найдена». < /p>
web.php (файл маршрута): < /strong> < /p>
Route::post('login', array(
'uses' => 'UserController@doLogin'
));
Route::get('logout', array('uses' => 'UserController@doLogout'));
Route::group(['middleware' => 'AuthMiddleWare'], function () {
Route::get('/form', function () {
return view('form');
});
Route::get('/createUser', function () {
return view('users');
});
Route::get('logout', array(
'uses' => 'UserController@doLogout'
));
});
< /code>
"Dologin" Коды функций, которые расположены в UserController: < /strong> < /p>
public function doLogin()
{
$rules = array(
'name' => 'required', // make sure the email is an actual email
'password' => 'required|alphaNum|min:3' // password can only be alphanumeric and has to be greater than 3 characters
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('login')
->withErrors($validator) // send back all errors to the login form
->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form
}
else {
// create our user data for the authentication
$userdata = array(
'name' => Input::get('name'),
'password' => Input::get('password')
);
$auth = DB::table('users')->where('name', '=', Input::get('name'))->where('password', '=', Input::get('password'))->get()->first();
// attempt to do the login
if (Auth::attempt($userdata)) {
// validation successful!
// redirect them to the secure section or whatever
// return Redirect::to('secure');
// for now we'll just echo success (even though echoing in a controller is bad)
echo 'SUCCESS!';
} else {
// validation not successful, send back to form
return Redirect::to('login');
}
}
}
< /code>
форма входа в систему: < /strong> < /p>
LOGIN
< /code>
Когда я смотрю на запрос входа в систему из кода статуса сети, появляющийся «302 найден». Когда я пытаюсь использовать $ auth < /strong> вместо «Auth :: попытка ($ userdata)» < /strong> все еще показывает одну и ту же ошибку. С другой стороны.
заранее спасибо. < /p>
Подробнее здесь: https://stackoverflow.com/questions/488 ... -302-found
Laravel Auth :: попытка 302 найдена ⇐ Php
Кемеровские программисты php общаются здесь
1750565260
Anonymous
Я новичок в Ларавеле. Я пытаюсь написать пример входа в систему, но он показывает ошибку «302 найдена». < /p>
web.php (файл маршрута): < /strong> < /p>
Route::post('login', array(
'uses' => 'UserController@doLogin'
));
Route::get('logout', array('uses' => 'UserController@doLogout'));
Route::group(['middleware' => 'AuthMiddleWare'], function () {
Route::get('/form', function () {
return view('form');
});
Route::get('/createUser', function () {
return view('users');
});
Route::get('logout', array(
'uses' => 'UserController@doLogout'
));
});
< /code>
"Dologin" Коды функций, которые расположены в UserController: < /strong> < /p>
public function doLogin()
{
$rules = array(
'name' => 'required', // make sure the email is an actual email
'password' => 'required|alphaNum|min:3' // password can only be alphanumeric and has to be greater than 3 characters
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('login')
->withErrors($validator) // send back all errors to the login form
->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form
}
else {
// create our user data for the authentication
$userdata = array(
'name' => Input::get('name'),
'password' => Input::get('password')
);
$auth = DB::table('users')->where('name', '=', Input::get('name'))->where('password', '=', Input::get('password'))->get()->first();
// attempt to do the login
if (Auth::attempt($userdata)) {
// validation successful!
// redirect them to the secure section or whatever
// return Redirect::to('secure');
// for now we'll just echo success (even though echoing in a controller is bad)
echo 'SUCCESS!';
} else {
// validation not successful, send back to form
return Redirect::to('login');
}
}
}
< /code>
форма входа в систему: < /strong> < /p>
LOGIN
< /code>
Когда я смотрю на запрос входа в систему из кода статуса сети, появляющийся «302 найден». Когда я пытаюсь использовать $ auth < /strong> вместо «Auth :: попытка ($ userdata)» < /strong> все еще показывает одну и ту же ошибку. С другой стороны.
заранее спасибо. < /p>
Подробнее здесь: [url]https://stackoverflow.com/questions/48879431/laravel-authattempt-302-found[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия