Answer the question
In order to leave comments, you need to log in
Work with authorization does not work correctly, what should I do?
I started making a site on L5 (just started) and got to authorization (I did it)).
Controller :
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
## Модели
use App\Models\Forum\Forum; // Модель форума
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;
use Redirect;
class AuthController extends Controller{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
protected $redirectTo = '/';
public function __construct(){
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
protected function validator(array $data){
return Validator::make($data, [
'login_users' => 'required|min:4|max:60',
'mail_users' => 'required|email|min:4|max:255|unique:users',
'password' => 'required|min:6|confirmed:password_confirmation',
'password_confirmation' => 'required|min:6',
'iAgree' => 'accepted'
]);
}
## Страница авторизация
public function getLogin(){
return view('Auth.getLogin');
}
public function postLogin(Request $request){
$data = $request->all();
$dataSave = $request->flashExcept('password');
$v = $this->validator($data);
if($v->fails()){
// Если есть ошибки
return redirect()->back()->withErrors($v->errors())->withInput($dataSave);
}else{
}
}
}
<div class="control-group {{($errors->first('login_users') ? 'error' : '')}}">
<label class="control-label" for="login_users">Логин:</label>
<div class="controls">
{{ Form::text('login_users', '', ['placeholder' => 'Введите ваш логин']) }}
<span class="help-inline">{{($errors->first('login_users') ? $errors->first('login_users') : '')}}</span>
</div>
</div>
<div class="control-group {{($errors->first('password') ? 'error' : '')}}">
<label class="control-label" for="password">Пароль:</label>
<div class="controls">
{{ Form::password('password', ['placeholder' => 'Введите ваш пароль']) }}
<span class="help-inline">{{($errors->first('password') ? $errors->first('password') : '')}}</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-success">Войти</button>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
In postLogin you check the validity of the authorization form with the rules for registration. so "Password not confirmed".
What to do?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question