Laravel Auth :: попытка 302 найденаPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Laravel Auth :: попытка 302 найдена

Сообщение 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>

Подробнее здесь: https://stackoverflow.com/questions/488 ... -302-found
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»