feat: complete login blade and controller

This commit is contained in:
2026-08-16 11:12:40 +03:30
parent d2f51a6e5c
commit 05bec33988
6 changed files with 51 additions and 17 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 KiB

+23 -2
View File
@@ -3,7 +3,10 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\Request; use App\Http\Requests\LoginPostRequest;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class LoginController extends Controller class LoginController extends Controller
{ {
@@ -16,8 +19,26 @@ class LoginController extends Controller
} }
public function post() public function post(LoginPostRequest $request)
{ {
$user = User::query()
->whereEmail($request->input('email'))
->first();
if (!$user) {
return back()->withErrors([
'general' => 'اطلاعات کاربر اشتباه است.'
])->withInput();
}
if (!Hash::check($request->input('password'), $user->password)) {
return back()->withErrors([
'general' => 'اطلاعات کاربر اشتباه است.'
])->withInput();
}
Auth::login($user);
return redirect()->route('index');
} }
} }
+4
View File
@@ -20,6 +20,10 @@
<img src="{{asset('assets/img/logo/logo-dark.png')}}" alt> <img src="{{asset('assets/img/logo/logo-dark.png')}}" alt>
<p>با حساب MyTrip خود وارد شوید</p> <p>با حساب MyTrip خود وارد شوید</p>
</div> </div>
@error('general')
<span style="color: red"> {{$message}}</span>
@enderror
<form action="{{route('auth.login.post')}}" <form action="{{route('auth.login.post')}}"
method="POST" method="POST"
> >
+3
View File
@@ -41,10 +41,13 @@
<option value="6">فرانک</option> <option value="6">فرانک</option>
</select> </select>
</div> </div>
@auth
@else
<div class="account"> <div class="account">
<a href="{{route('auth.login.index')}}"><i class="far fa-sign-in"></i>وارد شدن</a> <a href="{{route('auth.login.index')}}"><i class="far fa-sign-in"></i>وارد شدن</a>
<a href="{{route('auth.register.index')}}"><i class="far fa-user-tie"></i>ثبت نام</a> <a href="{{route('auth.register.index')}}"><i class="far fa-user-tie"></i>ثبت نام</a>
</div> </div>
@endauth
</div> </div>
</div> </div>
</div> </div>
+6
View File
@@ -123,9 +123,15 @@
<li class="nav-item"><a class="nav-link" href="contact.html">تماس باما</a></li> <li class="nav-item"><a class="nav-link" href="contact.html">تماس باما</a></li>
</ul> </ul>
<div class="header-nav-right"> <div class="header-nav-right">
@auth
<div class="header-btn"> <div class="header-btn">
<a href="{{ route('auth.logout.index') }}" class="theme-btn mt-2">خروج از حساب کاربری</a> <a href="{{ route('auth.logout.index') }}" class="theme-btn mt-2">خروج از حساب کاربری</a>
</div> </div>
@else
<div class="header-btn">
<a href="{{ route('auth.logout.index') }}" class="theme-btn mt-2">ورود به حساب کاربری</a>
</div>
@endauth
</div> </div>
</div> </div>
</div> </div>