Commit 73f3b25d authored by Waterfox's avatar Waterfox
Browse files

Add user functionnalities

parent b617c560
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -34,6 +34,16 @@ public function checkPassword($password)
            return false;
        }
    }

    public function roles()
    {
        return $this->belongsToMany(Role::class, 'CAR_ROLE_ATTRIBUTION', 'US_ID', 'ROL_CODE');
    }

    public function hasRole($roleCode)
    {
        return $this->roles->contains('ROL_CODE', $roleCode);
    }
}

?>
+0 −1
Original line number Diff line number Diff line
@@ -12,6 +12,5 @@
    @else
        <p>Unmatch</p>
    @endif

</body>
</html>
+23 −3
Original line number Diff line number Diff line
<?php

use Illuminate\Support\Facades\Route;

use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
@@ -12,11 +12,31 @@
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/login', function () {

use App\Models\User;

Route::get('/login', function ()
{
    return view('login');
});

use App\Models\User;
Route::post('/login', function (Request $request)
{
    $request->validate([
        'mail' => 'required|email',
        'password' => 'required',
    ]);

    $user = User::where('US_EMAIL', $request->mail)->first();
    if($user->checkPassword($request->password))
    {
        return redirect('/'); // TODO: Redirect to the user's hub page
    }
    else
    {
        return view('login', ['wrongPassword' => true]);
    }
});

Route::get('/', function () {
    return view('welcome');
+3 −3

File changed.

Contains only whitespace changes.