Mam taki problem piszę aplikacje w laravelu i teraz jak podam tylko nazwę użytkownika bez hasła to wchodzi natomiast jak już z hasłem to nie.
kod widoku
@extends('layout.index')
@section('content')
<form action={{ url('logowanie') }} method=post>
Twoj login
<input type="text" id="login2" size="5" class="form-control" name="name" value="{{Input::old('name')}}">
Twoje hasło
<input type="password" id="haslo" size="5" class="form-control" name="haslo">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button class="btn btn-primary">Zaloguj się</button>
@endsection
Kod controllera
public function logowanie() {
$haslo = Input::get('haslo');
//$a = Hash::make("");
//print $a;
//print Input::get('haslo');
$user = array(
'name' => Input::get('name'),
'password' => $haslo
);
//var_dump($user);
//var_dump($user);
if (Input::get('name') == "" and Input::get('haslo') == "" ) {
return Redirect('error')->with('login_error','Uzupełnij pole login i hasło');
//print "3";
}
if (Auth::attempt($user))
{
//print Auth::User()->id;
return Redirect('login');
}
else {
//print Input::get('login');
return Redirect('error')->with('login_error','Nieprawidłowy login lub hasło');
}
}