REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.66 KB
Close
/home/byroehnu/cnggold.com.ng/app/Http/Controllers/LoginLinkController.php
Text
Base64
<?php namespace App\Http\Controllers; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; use Inertia\Inertia; use Spatie\LoginLink\Exceptions\DidNotFindUserToLogIn; use Spatie\LoginLink\Exceptions\InvalidUserClass; use Spatie\LoginLink\Exceptions\NotAllowedInCurrentEnvironment; use Spatie\LoginLink\Http\Requests\LoginLinkRequest; class LoginLinkController extends Controller { public function __invoke(LoginLinkRequest $request) { $this->ensureAllowedEnvironment(); $authenticatable = $this->getAuthenticatable($request); $this->performLogin($request->guard, $authenticatable); $redirectUrl = $this->getRedirectUrl($request); return Inertia::location($redirectUrl); } protected function ensureAllowedEnvironment(): void { $allowedEnvironments = config('login-link.allowed_environments'); if (! app()->environment($allowedEnvironments)) { throw NotAllowedInCurrentEnvironment::make($allowedEnvironments); } } protected function getAuthenticatable(LoginLinkRequest $request): Authenticatable { $attributes = $this->getUserAttributes($request); $authenticatableClass = $this->getAuthenticatableClass($request->guard); $user = $authenticatableClass::query() ->when(count($attributes), fn (Builder $query) => $query->where($attributes)) ->first(); if ($user) { return $user; } if (! config('login-link.automatically_create_missing_users')) { throw DidNotFindUserToLogIn::make(); } return $this->createUser($authenticatableClass, $attributes); } protected function performLogin(?string $guard, Authenticatable $authenticatable): void { auth($guard)->login($authenticatable); } protected function getUserAttributes(LoginLinkRequest $request): array { $attributes = $request->userAttributes(); if ($identifier = $this->getAuthenticatableIdentifier($request)) { $attributes = array_merge([ $identifier['attribute'] => $identifier['value'], ], $attributes); } return $attributes; } protected function getAuthenticatableIdentifier(LoginLinkRequest $request): ?array { if ($request->key) { $userClass = new ($this->getAuthenticatableClass($request->guard)); return [ 'attribute' => ($userClass)->getKeyName(), 'value' => $request->key, ]; } if ($request->email) { return [ 'attribute' => 'email', 'value' => $request->email, ]; } return null; } protected function getAuthenticatableClass(?string $guard): string { $provider = $guard === null ? config('auth.guards.web.provider') : config("auth.guards.{$guard}.provider"); return config('login-link.user_model') ?? config("auth.providers.{$provider}.model") ?? throw InvalidUserClass::notFound(); } protected function createUser(string $authenticatableClass, array $attributes): Authenticatable { return $authenticatableClass::factory()->create($attributes); } protected function getRedirectUrl(LoginLinkRequest $request): string { if ($request->redirect_url) { return $request->redirect_url; } if ($routeName = config('login-link.redirect_route_name')) { return route($routeName); } return redirect()->intended()->getTargetUrl(); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 4 × Files: 6
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Admin
DIR
-
drwxr-xr-x
2025-07-19 07:29:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Auth
DIR
-
drwxr-xr-x
2025-05-08 11:48:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Debug
DIR
-
drwxr-xr-x
2025-04-08 04:12:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Frontend
DIR
-
drwxr-xr-x
2025-07-19 07:29:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Controller.php
336 B
lrw-r--r--
2025-04-19 04:22:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DebugController.php
3.48 KB
lrw-r--r--
2025-07-19 11:19:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InstallController.php
8.61 KB
lrw-r--r--
2025-07-19 11:26:12
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LoginLinkController.php
3.66 KB
lrw-r--r--
2025-05-04 10:26:05
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProfileController.php
1.48 KB
lrw-r--r--
2025-04-08 04:12:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UpdateController.php
3.97 KB
lrw-r--r--
2025-07-19 12:08:07
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).