Answer the question
In order to leave comments, you need to log in
How does laravel Auth controller know which field to encrypt?
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Auth;
use Illuminate\Support\Facades\Redirect;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
'login' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'pass' => 'required|confirmed|min:6',
]);
}
protected function create(array $data)
{
$user=new User;
$user->login= $data['login'];
$user->email=$data['email'];
$user->pass=bcrypt($data['pass']);
$user->save();
}
public function authenticate(Request $request)
{ $login=$request->input('login');
$pass=$request->input('pass');
$validator = Validator::make($request->all(), [
'login'=>'required',
'pass'=>'required'
]);
if ($validator->fails()) {
return Redirect::to('auth/login')
->withErrors($validator)
->withInput();
} else {
if (Auth::attempt(['login' => $login , 'pass' => $pass ])) {
return redirect()->intended('home');
}
return Redirect::to('auth/login')
->withErrors('Wrong login/pass');
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question