-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #4 - wip, basic login * #4 - wip * #4 - wip * #4 - wip * #4 - wip * #4 - fixed bugs with logout, changes in routing * #4 - fixed students tests
- Loading branch information
1 parent
ddbb902
commit 75393f2
Showing
18 changed files
with
508 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Dashboard; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class LogoutController extends Controller | ||
{ | ||
public function __invoke(Request $request): RedirectResponse | ||
{ | ||
Auth::logout(); | ||
|
||
$request->session()->invalidate(); | ||
|
||
$request->session()->regenerateToken(); | ||
|
||
return redirect()->route("main"); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/Http/Controllers/Dashboard/PasswordUpdateController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Dashboard; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Validation\Rules\Password; | ||
use Inertia\Response; | ||
|
||
class PasswordUpdateController extends Controller | ||
{ | ||
public function edit(): Response | ||
{ | ||
return inertia("Dashboard/PasswordUpdate"); | ||
} | ||
|
||
public function update(Request $request): RedirectResponse | ||
{ | ||
$validated = $request->validate([ | ||
"current_password" => ["required", "current_password"], | ||
"password" => ["required", Password::defaults(), "confirmed"], | ||
]); | ||
|
||
$request->user()->update([ | ||
"password" => Hash::make($validated["password"]), | ||
]); | ||
|
||
return redirect()->back() | ||
->with("success", "Zaktualizowano hasło"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Public; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Inertia\Response; | ||
|
||
class LoginController extends Controller | ||
{ | ||
public function create(): Response | ||
{ | ||
return inertia("Public/Login", [ | ||
"universityLogo" => "https://irg2023.collegiumwitelona.pl/assets/logos/cwup.png", | ||
]); | ||
} | ||
|
||
public function store(Request $request): RedirectResponse | ||
{ | ||
$credentials = $request->only("email", "password"); | ||
|
||
if (Auth::attempt($credentials)) { | ||
$request->session()->regenerate(); | ||
|
||
return redirect()->route("dashboard"); | ||
} | ||
|
||
return back()->withErrors([ | ||
"email" => "Niepoprawne dane logowania", | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.