使用表单创建请求身份验证



我需要管理对帐户的访问,特别是我想创建一个表单,询问用户凭据 用户和密码 数据库中已经存在,并在对它们进行身份验证后
将我重定向到用户的页面,但我不知道如何处理身份验证。

路线:

Route::get('/registrazione/store2','RegistrazioniController@store2')->name('registrazione.store2');

控制器:

public function store2(tabella_utenti $utente,Request $request)
{
$user = User::where('email', $request->email);
$utenteId=$utente->id;
return redirect(route('utente.show',compact('utenteId')));
}
public function show(tabella_utenti $utente)
{
return view('registrazione.utenteShow',compact('utente'));
}

视图:

<!--form accesso-->
<div style="display: none; margin-left: 550px" id="form2">
<h2 style="color: red">Accedi</h2>
{!! Form::open(['route'=>'registrazione.store2']) !!}
<div class="form-group">
{!! Form::label('email','Email',['style'=>'h3']) !!}
{!! Form::text('email','',['class'=>'form-control','style'=>'width:220px','placeholder'=>'Inserisci@la mail']) !!}
</div>
<div class="form-group">
{!! Form::label('password','Password',['style'=>'h3']) !!}
{!! Form::text('password','',['class'=>'form-control','style'=>'width:220px','placeholder'=>'inserisci la password' ]) !!}
</div>
{!! Form:: submit('accedi',['class'=>' btn btn-primary']) !!}
<a class="btn btn-success" href="{{route('homepage')}}"> home </a>
{!! Form::close() !!}
</div>

为了在 laravel 中使用身份验证。

最好使用内置功能来处理身份验证,而不是从头开始创建

它使用 PHP Artisan make:Auth(( 在 Laravel 中生成基本身份验证

按照文档进行操作,然后如果需要,可以根据需要对其进行自定义。

文档:https://laravel.com/docs/5.X/authentication(将 5.X 更改为您的 laravel 版本(

最新更新