-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b8c4de
commit ebc1a28
Showing
62 changed files
with
5,302 additions
and
1,140 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
app/Http/Controllers/Auth/AuthenticatedSessionController.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,52 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Interns2024c\Http\Requests\Auth\LoginRequest; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Route; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class AuthenticatedSessionController extends Controller | ||
{ | ||
/** | ||
* Display the login view. | ||
*/ | ||
public function create(): Response | ||
{ | ||
return Inertia::render('Auth/Login', [ | ||
'canResetPassword' => Route::has('password.request'), | ||
'status' => session('status'), | ||
]); | ||
} | ||
|
||
/** | ||
* Handle an incoming authentication request. | ||
*/ | ||
public function store(LoginRequest $request): RedirectResponse | ||
{ | ||
$request->authenticate(); | ||
|
||
$request->session()->regenerate(); | ||
|
||
return redirect()->intended(route('dashboard', absolute: false)); | ||
} | ||
|
||
/** | ||
* Destroy an authenticated session. | ||
*/ | ||
public function destroy(Request $request): RedirectResponse | ||
{ | ||
Auth::guard('web')->logout(); | ||
|
||
$request->session()->invalidate(); | ||
|
||
$request->session()->regenerateToken(); | ||
|
||
return redirect('/'); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/Http/Controllers/Auth/ConfirmablePasswordController.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,41 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Validation\ValidationException; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class ConfirmablePasswordController extends Controller | ||
{ | ||
/** | ||
* Show the confirm password view. | ||
*/ | ||
public function show(): Response | ||
{ | ||
return Inertia::render('Auth/ConfirmPassword'); | ||
} | ||
|
||
/** | ||
* Confirm the user's password. | ||
*/ | ||
public function store(Request $request): RedirectResponse | ||
{ | ||
if (! Auth::guard('web')->validate([ | ||
'email' => $request->user()->email, | ||
'password' => $request->password, | ||
])) { | ||
throw ValidationException::withMessages([ | ||
'password' => __('auth.password'), | ||
]); | ||
} | ||
|
||
$request->session()->put('auth.password_confirmed_at', time()); | ||
|
||
return redirect()->intended(route('dashboard', absolute: false)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/Http/Controllers/Auth/EmailVerificationNotificationController.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,24 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
|
||
class EmailVerificationNotificationController extends Controller | ||
{ | ||
/** | ||
* Send a new email verification notification. | ||
*/ | ||
public function store(Request $request): RedirectResponse | ||
{ | ||
if ($request->user()->hasVerifiedEmail()) { | ||
return redirect()->intended(route('dashboard', absolute: false)); | ||
} | ||
|
||
$request->user()->sendEmailVerificationNotification(); | ||
|
||
return back()->with('status', 'verification-link-sent'); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/Http/Controllers/Auth/EmailVerificationPromptController.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,22 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class EmailVerificationPromptController extends Controller | ||
{ | ||
/** | ||
* Display the email verification prompt. | ||
*/ | ||
public function __invoke(Request $request): RedirectResponse|Response | ||
{ | ||
return $request->user()->hasVerifiedEmail() | ||
? redirect()->intended(route('dashboard', absolute: false)) | ||
: Inertia::render('Auth/VerifyEmail', ['status' => session('status')]); | ||
} | ||
} |
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,69 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Auth\Events\PasswordReset; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Password; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Validation\Rules; | ||
use Illuminate\Validation\ValidationException; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class NewPasswordController extends Controller | ||
{ | ||
/** | ||
* Display the password reset view. | ||
*/ | ||
public function create(Request $request): Response | ||
{ | ||
return Inertia::render('Auth/ResetPassword', [ | ||
'email' => $request->email, | ||
'token' => $request->route('token'), | ||
]); | ||
} | ||
|
||
/** | ||
* Handle an incoming new password request. | ||
* | ||
* @throws \Illuminate\Validation\ValidationException | ||
*/ | ||
public function store(Request $request): RedirectResponse | ||
{ | ||
$request->validate([ | ||
'token' => 'required', | ||
'email' => 'required|email', | ||
'password' => ['required', 'confirmed', Rules\Password::defaults()], | ||
]); | ||
|
||
// Here we will attempt to reset the user's password. If it is successful we | ||
// will update the password on an actual user model and persist it to the | ||
// database. Otherwise we will parse the error and return the response. | ||
$status = Password::reset( | ||
$request->only('email', 'password', 'password_confirmation', 'token'), | ||
function ($user) use ($request) { | ||
$user->forceFill([ | ||
'password' => Hash::make($request->password), | ||
'remember_token' => Str::random(60), | ||
])->save(); | ||
|
||
event(new PasswordReset($user)); | ||
} | ||
); | ||
|
||
// If the password was successfully reset, we will redirect the user back to | ||
// the application's home authenticated view. If there is an error we can | ||
// redirect them back to where they came from with their error message. | ||
if ($status == Password::PASSWORD_RESET) { | ||
return redirect()->route('login')->with('status', __($status)); | ||
} | ||
|
||
throw ValidationException::withMessages([ | ||
'email' => [trans($status)], | ||
]); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Validation\Rules\Password; | ||
|
||
class PasswordController extends Controller | ||
{ | ||
/** | ||
* Update the user's password. | ||
*/ | ||
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 back(); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Password; | ||
use Illuminate\Validation\ValidationException; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class PasswordResetLinkController extends Controller | ||
{ | ||
/** | ||
* Display the password reset link request view. | ||
*/ | ||
public function create(): Response | ||
{ | ||
return Inertia::render('Auth/ForgotPassword', [ | ||
'status' => session('status'), | ||
]); | ||
} | ||
|
||
/** | ||
* Handle an incoming password reset link request. | ||
* | ||
* @throws \Illuminate\Validation\ValidationException | ||
*/ | ||
public function store(Request $request): RedirectResponse | ||
{ | ||
$request->validate([ | ||
'email' => 'required|email', | ||
]); | ||
|
||
// We will send the password reset link to this user. Once we have attempted | ||
// to send the link, we will examine the response then see the message we | ||
// need to show to the user. Finally, we'll send out a proper response. | ||
$status = Password::sendResetLink( | ||
$request->only('email') | ||
); | ||
|
||
if ($status == Password::RESET_LINK_SENT) { | ||
return back()->with('status', __($status)); | ||
} | ||
|
||
throw ValidationException::withMessages([ | ||
'email' => [trans($status)], | ||
]); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Interns2024c\Models\User; | ||
use Illuminate\Auth\Events\Registered; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Validation\Rules; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class RegisteredUserController extends Controller | ||
{ | ||
/** | ||
* Display the registration view. | ||
*/ | ||
public function create(): Response | ||
{ | ||
return Inertia::render('Auth/Register'); | ||
} | ||
|
||
/** | ||
* Handle an incoming registration request. | ||
* | ||
* @throws \Illuminate\Validation\ValidationException | ||
*/ | ||
public function store(Request $request): RedirectResponse | ||
{ | ||
$request->validate([ | ||
'name' => 'required|string|max:255', | ||
'email' => 'required|string|lowercase|email|max:255|unique:'.User::class, | ||
'password' => ['required', 'confirmed', Rules\Password::defaults()], | ||
]); | ||
|
||
$user = User::create([ | ||
'name' => $request->name, | ||
'email' => $request->email, | ||
'password' => Hash::make($request->password), | ||
]); | ||
|
||
event(new Registered($user)); | ||
|
||
Auth::login($user); | ||
|
||
return redirect(route('dashboard', absolute: false)); | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace Interns2024c\Http\Controllers\Auth; | ||
|
||
use Interns2024c\Http\Controllers\Controller; | ||
use Illuminate\Auth\Events\Verified; | ||
use Illuminate\Foundation\Auth\EmailVerificationRequest; | ||
use Illuminate\Http\RedirectResponse; | ||
|
||
class VerifyEmailController extends Controller | ||
{ | ||
/** | ||
* Mark the authenticated user's email address as verified. | ||
*/ | ||
public function __invoke(EmailVerificationRequest $request): RedirectResponse | ||
{ | ||
if ($request->user()->hasVerifiedEmail()) { | ||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); | ||
} | ||
|
||
if ($request->user()->markEmailAsVerified()) { | ||
event(new Verified($request->user())); | ||
} | ||
|
||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); | ||
} | ||
} |
Oops, something went wrong.