feat:implement RegisterController.php
This commit is contained in:
@@ -3,17 +3,43 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginPostRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$withoutHeader = true;
|
||||
$withoutFooter = true;
|
||||
|
||||
return view('auth.login', compact('withoutHeader', 'withoutFooter'));
|
||||
}
|
||||
|
||||
public function post()
|
||||
public function post(LoginPostRequest $request)
|
||||
{
|
||||
$user = User::query()
|
||||
->whereMobile($request->input('mobile'))
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
|
||||
return back()->withErrors([
|
||||
'general' => 'اطلاعات کاربر اشتباه است.'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!Hash::check($request->input('password'), $user->password)){
|
||||
return back()->withErrors([
|
||||
'general' => 'اطلاعات کاربر اشتباه است.'
|
||||
]);
|
||||
}
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect()->route('index');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user