我试图进行基本身份验证,我遇到很多问题,主要是这个
发送表单并尝试进行身份验证时出现此错误
叶片
{{ Form::open(array('url' => 'usuario')) }}
<input type="text" class="text" id="email" name="email" placeholder="Correo" {{(Input::old('email')) ? 'value ="'. Input::old('email').'"' : '' }}>
<p>{{ $errors->first('email') }}</p>
<input type="text" class="text" id="password" name="password" placeholder="Contraseña" >
<p>{{ $errors->first('password') }}</p>
{{ Form::submit('Ingresar', array('class' => 'bg1')) }}
{{ Form::close() }}
路线
Route::post('usuario', array('as' => 'usuario', 'uses' => 'UsuarioController@doLogin'));
模型
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class Usuario extends Eloquent implements UserInterface, RemindableInterface{
protected $table = 'Usuario';
protected $primaryKey = 'idUsuario';
protected $hidden = array('Contrasena');
protected $fillable = array(
'Nombre',
'Apellido',
'Tipo',
'Contrasena',
'Correo',
'Fono',
'Foto'
);
}
控制器
class UsuarioController extends BaseController{
public function doLogin(){
$rules = array(
'email' => 'required|email',
'password' => 'required'
);
$validator = Validator::make(Input::all(), $rules);
if($validator->fails()){
return Redirect::to('usuario')->withErrors($validator)->withInput(Input::except('password'));
}else{
$userdata = array(
'Correo' => Input::get('email'),
'Password' => Input::get('password')
);
if(Auth::attemp($userdata)){
return View::make('hello');
}else{
return Redirect::to('usuario');
}
}
}
}
验证
'driver' => 'database',
'model' => 'Usuario',
'table' => 'Usuario',
请问,我该如何解决?
答案 0 :(得分:5)
因为attemp
应为attempt
:
if(Auth::attemp($userdata))
应该是:
if(Auth::attempt($userdata))