Answer the question
In order to leave comments, you need to log in
Login through laravel does not work and I can't find the reason)?
Controller code
public function login(Request $request){
if (Auth::check()){
return redirect(route('Account'));
}
$formFields = $request->only(['Login', 'Password']);
// dd($formFields);
if(Auth::attempt($formFields)){
return redirect()->intended(route('Account'));
}
return redirect(route('LoginPage'))->withErrors([
'Login' => 'Произошла ошибка при входе!',
]);
}
return redirect(route('LoginPage'))->withErrors([
'Login' => 'Произошла ошибка при входе!',
]);
public function setPasswordAttribute($password){
$this->attributes['Password'] = Hash::make($password);
}
<div class="FormAuth">
<p class="p7">Вход</p>
<form class="formReg" action="{{route('login')}}" method="POST">
@csrf
<input type="text" name="Login" value="" placeholder="Введите логин" class="input">
@error('Login')
<div><p class="p6">{{$message}}</p></div>
@enderror
<input type="password" name="Password" value="" placeholder="Введите пароль" class="input">
@error('Password')
<div><p>{{$message}}</p></div>
@enderror
<button type="submit" class="btn-reg log-btn" value="#"><p class="p9">Войти</p></button>
</form>
<a href="{{route('Authentication')}}" class="cnp-auth"><p class="p9 pCorrected">Нажмите сюда если хотите зарегистрироваться!</p></a>
</div>
Answer the question
In order to leave comments, you need to log in
Krch problem with the names in the database you can not write Password instead of password, I found that supposedly this function replaces the standard name
public function getAuthPassword()
{
return $this->attributes['Название твоего столбца в бд'];
// или
return $this->Название твоего столбца в бд;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question